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

 ID:                 47126
 Comment by:         t dot weber at digi-info dot de
 Reported by:        a dot u dot savchuk at gmail dot com
 Summary:            copy() caches incorrect stat info of file-target
 Status:             No Feedback
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   linux
 PHP Version:        5.2.8
 Block user comment: N
 Private report:     N

 New Comment:

Since the original reporter doesn’t seem to be interested in it anymore, 
I’m 
speaking up.

This bug is still present in PHP 5.3.10.

I agree with the original reporter that the documentation should be updated. 
However, I have not looked into PHP’s source code and cannot comment on his 
proposed solution.


Previous Comments:
------------------------------------------------------------------------
[2009-12-23 01:00:01] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------
[2009-12-15 01:03:07] fel...@php.net

Please try using this snapshot:

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

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



------------------------------------------------------------------------
[2009-04-09 01:00:01] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------
[2009-04-01 11:11:23] j...@php.net

Please try using this CVS snapshot:

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

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



------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=47126&edit=1

Reply via email to