From: gu_ludo at yahoo dot com dot br Operating system: WinXP SP3 PHP version: 5.3.23 Package: Filesystem function related Bug Type: Bug Bug description:filemtime() and 'mtime' index from stat() only works for the first call
Description: ------------ The functions stat() and filemtime() don't return a different value for the file's modification time on a second call whereas fstat() does. Test script: --------------- echo "Using filemtime():\n"; $filename = tempnam(sys_get_temp_dir(), 'foo'); file_put_contents($filename, "First row\n", FILE_APPEND); var_dump(filemtime($filename)); sleep(5); file_put_contents($filename, "Second row\n", FILE_APPEND); var_dump(filemtime($filename)); echo "\nUsing stat():\n"; $filename = tempnam(sys_get_temp_dir(), 'foo'); file_put_contents($filename, "First row\n", FILE_APPEND); $stat = stat($filename); var_dump($stat['mtime']); sleep(5); file_put_contents($filename, "Second row\n", FILE_APPEND); $stat = stat($filename); var_dump($stat['mtime']); echo "\nUsing fstat():\n"; $filename = tempnam(sys_get_temp_dir(), 'foo'); $f = fopen($filename, 'r'); file_put_contents($filename, "First row\n", FILE_APPEND); $stat = fstat($f); var_dump($stat['mtime']); sleep(5); file_put_contents($filename, "Second row\n", FILE_APPEND); $stat = fstat($f); var_dump($stat['mtime']); Expected result: ---------------- Using filemtime(): int(1364217934) int(1364217939) Using stat(): int(1364217939) int(1364217944) Using fstat(): int(1364217944) int(1364217949) Actual result: -------------- Using filemtime(): int(1364217934) int(1364217934) Using stat(): int(1364217939) int(1364217939) Using fstat(): int(1364217944) int(1364217949) -- Edit bug report at https://bugs.php.net/bug.php?id=64510&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64510&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64510&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64510&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64510&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64510&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64510&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64510&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64510&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64510&r=support Expected behavior: https://bugs.php.net/fix.php?id=64510&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64510&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64510&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64510&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64510&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64510&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64510&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64510&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64510&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64510&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64510&r=mysqlcfg