ID:               47126
 Updated by:       j...@php.net
 Reported By:      a dot u dot savchuk at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Filesystem function related
 Operating System: linux
 PHP Version:      5.2.8
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/




Previous Comments:
------------------------------------------------------------------------

[2009-01-16 12:17:08] a dot u dot savchuk at gmail dot com

Description:
------------
Function copy() has a bug (or strange behavior).

When you copy file to _already_ existed file-target,
then info of this file-target will be cached before rewrite.

Workaround here is usage of clearstatcache().

Also other problem is that copy() function is not listed in list of
cached functions in manual for clearstatcache().

As i understand from source code, the problem is that copy() uses
php_stream_stat_path_ex() [ _php_stream_stat_path() ] function which
stores stat info in cache. Correct solutions are:
1. add parameter to php_stream_stat_path_ex() to not store info to
cache and call it for destination path in php_copy_file_ex()
2. clear cache after successfull call of php_stream_stat_path_ex() for
destination path in php_copy_file_ex().



Reproduce code:
---------------
<?php

$source = '/t1.t';
$target = '/t2.t';

file_put_contents($source, 'aaaaaaaaaa');
file_put_contents($target, 'a');
clearstatcache( true );

copy( $source, $target );

var_dump( filesize($target) );
?>


Expected result:
----------------
int(10)


Actual result:
--------------
int(1)



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47126&edit=1

Reply via email to