note 117590 added to function.rename
| From: | ben at indietorrent dot org | Date: | Thu, 02 Jul 2015 15:31:52 +0000 |
| Subject: | note 117590 added to function.rename | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203030@lists.php.net to get a copy of this message | ||
From the Changelog notes:
"Warnings may be generated if the destination filesystem doesn't permit chown() or chmod()
system calls to be made on files â for example, if the destination filesystem is a FAT
filesystem."
More explicitly, rename() may still return (bool) true, despite the warnings that result from the
underlying calls to chown() or chmod(). This behavior can be misleading absent a deeper
understanding of the underlying mechanics. To rename across filesystems, PHP "fakes it" by
calling copy(), unlink(), chown(), and chmod() (not necessarily in that order). See PHP bug #50676
for more information.
On UNIX-like operating systems, filesystems may be mounted with an explicit uid and/or gid (for
example, with mount options "uid=someuser,gid=somegroup"). Attempting to call rename()
with such a destination filesystem will cause an "Operation not permitted" warning, even
though the file is indeed renamed and rename() returns (bool) true.
This is not a bug. Either handle the warning as is appropriate to your use-case, or call copy() and
then unlink(), which will avoid the doomed calls to chown() and chmod(), thereby eliminating the
warning.
----
Server IP: 72.52.91.14
Probable Submitter: 66.63.85.34
----
Manual Page -- http://php.net/manual/en/function.rename.php
Edit -- https://master.php.net/note/edit/117590
Del: integrated -- https://master.php.net/note/delete/117590/integrated
Del: useless -- https://master.php.net/note/delete/117590/useless
Del: bad code -- https://master.php.net/note/delete/117590/bad+code
Del: spam -- https://master.php.net/note/delete/117590/spam
Del: non-english -- https://master.php.net/note/delete/117590/non-english
Del: in docs -- https://master.php.net/note/delete/117590/in+docs
Del: other reasons-- https://master.php.net/note/delete/117590
Reject -- https://master.php.net/note/reject/117590
Search -- https://master.php.net/manage/user-notes.php