note 113943 added to function.rename

From: Date: Thu, 19 Dec 2013 23:35:46 +0000
Subject: note 113943 added to function.rename
Groups: php.notes 
Request: Send a blank email to php-notes+get-197985@lists.php.net to get a copy of this message
Important note - rename() does NOT work for *directories* across filesystems or devices. Only *files* You will get two warnings: "PHP Warning: rename(): The first argument to copy() function cannot be a directory in <whatever> on line <whatever>" "PHP Warning: rename(t2,/var/run/test/t2): Invalid cross-device link in <whatever> on line <whatever>" The copy() mentioned I assume is C's copy() and not PHP's copy() function. There is an associated bug in the Ubuntu bug system for this as well, that was escalated to bugs.php.net: https://bugs.php.net/bug.php?id=54097 The only workarounds right now I believe is using PHP copy($source, $dest) and then on success, PHP unlink($source), or doing system("mv $source $dest") which is hokey, and should be surrounded by quotes for paths with spaces or other shell metacharacters, and possibly escaped for security. ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/function.rename.php Edit -- https://master.php.net/note/edit/113943 Del: integrated -- https://master.php.net/note/delete/113943/integrated Del: useless -- https://master.php.net/note/delete/113943/useless Del: bad code -- https://master.php.net/note/delete/113943/bad+code Del: spam -- https://master.php.net/note/delete/113943/spam Del: non-english -- https://master.php.net/note/delete/113943/non-english Del: in docs -- https://master.php.net/note/delete/113943/in+docs Del: other reasons-- https://master.php.net/note/delete/113943 Reject -- https://master.php.net/note/reject/113943 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#197985) next »