Doc #63473 [Com]: rename rename
| From: | anon at anon dot anon | Date: | Tue, 13 Nov 2012 06:56:01 +0000 |
| Subject: | Doc #63473 [Com]: rename rename | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-9108@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63473&edit=1
ID: 63473
Comment by: anon at anon dot anon
Reported by: anon at anon dot anon
Summary: rename rename
Status: Closed
Type: Documentation Problem
Package: Documentation problem
PHP Version: 5.4.8
Assigned To: aharvey
Block user comment: N
Private report: N
New Comment:
Alright, thanks.
Previous Comments:
------------------------------------------------------------------------
[2012-11-12 02:00:41] aharvey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.
------------------------------------------------------------------------
[2012-11-12 02:00:39] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=328311
Log: Update the rename() description to note that it overwrites and moves between
directories.
Fixes doc bug #63473 (rename rename).
------------------------------------------------------------------------
[2012-11-12 01:56:36] aharvey@php.net
I'll update the manual to indicate that it overwrites the destination, but the behaviour of the
function is expected: it has the same semantics as the rename() C library function.
------------------------------------------------------------------------
[2012-11-09 18:39:01] anon at anon dot anon
Apparently PHP doesn't even have a way to merely rename a file. Using file_exists with rename
will be vulnerable to race conditions (potential file overwrites) with other processes.
------------------------------------------------------------------------
[2012-11-09 18:32:42] anon at anon dot anon
Description:
------------
The rename function overwrites. This is totally unexpected and unintuitive behavior which could
cause data loss, and it is not even documented.
Combined with the fact that the rename function can "rename" across drives, it's
obviously a move, not a rename. Then it should be called move, so you can tell what it does.
Test script:
---------------
<?php
file_put_contents('1.txt', 'one');
file_put_contents('2.txt', 'two');
rename('2.txt', '1.txt');
echo '1.txt:' . file_get_contents('1.txt');
echo '2.txt:' . file_get_contents('2.txt');
Expected result:
----------------
1.txt:one
2.txt:two
plus an error that the name exists
Actual result:
--------------
1.txt:two
2.txt:
plus an error that 2.txt does not exist
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63473&edit=1