|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-12-05 01:48 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2015-12-05 01:48 UTC] requinix@php.net
[2015-12-09 19:02 UTC] info at mikekeran dot com
[2015-12-09 19:30 UTC] requinix@php.net
[2015-12-09 19:39 UTC] info at mikekeran dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 17:00:01 2025 UTC |
Description: ------------ When using rename to replace an existing file, PHP on Windows incorrectly gives an access denied if the target file is read-only (0444): An access denied error should only be given if the target file's directory permissions should keep the current user from writing to that location. Linux (tested on Ubuntu 14.04) works as expected. Test script: --------------- <?php file_put_contents('./test.txt', 'test data'); file_put_contents('./newtest.txt', 'new test data'); chmod('test.txt', 0666); rename('newtest.txt', 'test.txt'); print "test.txt is now: " . file_get_contents('./test.txt') . "\n"; file_put_contents('./test.txt', 'test data'); file_put_contents('./newtest.txt', 'new test data'); chmod('test.txt', 0444); rename('newtest.txt', 'test.txt'); print "test.txt is now: " . file_get_contents('./test.txt') . "\n"; Expected result: ---------------- test.txt is now: new test data test.txt is now: new test data Actual result: -------------- test.txt is now: new test data Warning: rename(newtest.txt,test.txt): Access is denied. (code: 5) in C:\Users\Mike\Documents\dev\sandbox\sandbox.php on line 13 test.txt is now: test data