From:             anon at anon dot anon
Operating system: 
PHP version:      5.4.8
Package:          Filesystem function related
Bug Type:         Bug
Bug description:rename rename

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 bug report at https://bugs.php.net/bug.php?id=63473&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=63473&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=63473&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=63473&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=63473&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=63473&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=63473&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=63473&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=63473&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=63473&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=63473&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=63473&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=63473&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=63473&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63473&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=63473&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=63473&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=63473&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63473&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=63473&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=63473&r=mysqlcfg

Reply via email to