note 119408 deleted from function.rename by cmb
| From: | cmb@php.net | Date: | Sun, 22 Dec 2019 09:11:46 +0000 |
| Subject: | note 119408 deleted from function.rename by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213601@lists.php.net to get a copy of this message | ||
Note Submitter: _php_
----
If $source is a valid folder, what do you think this does:
<?php
rename($source, '@');
?>
In 99% of the time you will get a warning, and $source remains untouched.
However, if you're working on Windows, and on a mapped network drive occasionally $source will
be moved to folder '@' which will be located at PHP's working directory.
How about this:
<?php
rename($source, $source . '\folder1');
?>
This makes $source inaccessible.
Of course, it's stupid to move $source into a sub-folder like that. I'd expect an error.
Yet, no error or warning. And the script "freezes".
I had few instances where rename simply deleted files & folders. I have not been able figure out
why.
In a nut shell, be-careful when using rename.