From: a dot u dot savchuk at gmail dot com Operating system: linux PHP version: 5.2.8 PHP Bug Type: Filesystem function related Bug description: copy() caches incorrect stat info of file-target
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 bug report at http://bugs.php.net/?id=47126&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47126&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47126&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47126&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47126&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47126&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47126&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47126&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47126&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47126&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47126&r=support Expected behavior: http://bugs.php.net/fix.php?id=47126&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47126&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47126&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47126&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47126&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47126&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47126&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47126&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47126&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47126&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47126&r=mysqlcfg
