From: rasmus at mindplay dot dk Operating system: WindowsXP/DebianLinux PHP version: 5.2.5 PHP Bug Type: Filesystem function related Bug description: rename() function is not portable to Windows
Description: ------------ The behavior of rename() is inconsistent between Linux and Windows. On Linux, the rename() function is atomic - you can rename() one file over an existing file, and the replacement is atomic. On Windows, you cannot rename over an existing file. Reproduce code: --------------- <?php file_put_contents("file1.txt", "this is file 1"); file_put_contents("file2.txt", "this is file 2"); rename("file1.txt", "file2.txt"); echo "reading file 2: "; readfile("file2.txt"); ?> Expected result: ---------------- reading file 2: this is file 1 Actual result: -------------- On Linux: (CORRECT) reading file 2: this is file 1 On Windows: (INCORRECT) Warning: rename(file1.txt,file2.txt) [function.rename]: File exists in C:\Web3\test\rename\test.php on line 6 reading file 2: this is file 2 -- Edit bug report at http://bugs.php.net/?id=44805&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44805&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44805&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44805&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44805&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44805&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44805&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44805&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44805&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44805&r=support Expected behavior: http://bugs.php.net/fix.php?id=44805&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44805&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44805&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44805&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44805&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44805&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44805&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44805&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44805&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44805&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44805&r=mysqlcfg