Bug #72666 [NEW]: touch(): stat cache clearing inconsistent between file:// paths and plain paths

From: Date: Mon, 25 Jul 2016 07:37:03 +0000
Subject: Bug #72666 [NEW]: touch(): stat cache clearing inconsistent between file:// paths and plain paths
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202562@lists.php.net to get a copy of this message
From: phofstetter at sensational dot ch Operating system: MacOS X and Linux PHP version: 7.1.0beta1 Package: Streams related Bug Type: Bug Bug description:touch(): stat cache clearing inconsistent between file:// paths and plain paths Description: ------------ When calling touch() on a plain path, the stat cache doesn't get cleared. However, when calling touch() on a 'file://' URL, the stat cache gets cleared by virtue of php_plain_files_metadata which clears the stat cache after all operations. This leads to the behaviour as shown in the test script (output available here: https://3v4l.org/0VQIo) Furthermore: fopen(), fwrite(), fclose() does not clear the stat cache in either case and neither does file_put_contents(). I would create a PR to fix the touch() case, but in general, it's probably worth reconsidering the usefulness of the stat-cache these days. Even over an NFS link, when doing nothing but stat()'ing, you still only lose about 10% performance if you call clearstatcache() after every stat(). Plus, the cache really only helps when you continuously stat() the same file within the same request, which probably isn't correct application behaviour anyways. So in general, I would propose to actually kill the stat cache which would fix this inconsistency as well :-) Test script: --------------- <?php // doesn't update realpath cache touch('/tmp/foo'); var_dump(filemtime('/tmp/foo')); touch('/tmp/foo', 1); var_dump(filemtime('/tmp/foo')); // does update the realpath cache touch('file:///tmp/foo'); var_dump(filemtime('file:///tmp/foo')); touch('file:///tmp/foo', 1); var_dump(filemtime('file:///tmp/foo')); Expected result: ---------------- int(1469202653) int(1) int(1469202653) int(1) Actual result: -------------- int(1469202653) int(1469202653) int(1469202653) int(1) -- Edit bug report at https://bugs.php.net/bug.php?id=72666&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72666&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72666&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72666&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72666&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72666&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72666&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72666&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72666&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72666&r=support Expected behavior: https://bugs.php.net/fix.php?id=72666&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72666&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72666&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72666&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72666&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72666&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72666&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72666&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72666&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72666&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72666&r=mysqlcfg

« previous php.bugs (#202562) next »