Bug #77595 [Opn->Nab]: concurrent processes prevent filesize() from working

From: Date: Sun, 10 Feb 2019 21:29:44 +0000
Subject: Bug #77595 [Opn->Nab]: concurrent processes prevent filesize() from working
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219475@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77595&edit=1 ID: 77595 Updated by: krakjoe@php.net Reported by: Wes dot nospam at example dot org Summary: concurrent processes prevent filesize() from working -Status: Open +Status: Not a bug Type: Bug Package: *Directory/Filesystem functions Operating System: Windows PHP Version: 7.2.15 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2019-02-10 05:43:00] Wes dot nospam at example dot org Description: ------------ other processes are denied to write the file while it is shared-locked, but attempting to do so prevents filesize() from working Test script: --------------- <?php // create a file of 6 bytes $path = __DIR__ . "/foo.txt"; file_put_contents($path, "123456"); // (1) // open that file for read and shared-lock it $file = fopen($path, "r"); flock($file, LOCK_SH | LOCK_NB); // (2) // attempt to write that file concurrently while the lock is active echo php -r "file_put_contents('$path', 'baz');"; // this step fails as expected -- means the file is still "123456" // (3) // attempt to read the file's size clearstatcache(FALSE, $path); $fileSize = filesize($path); // should return 6 bytes but returns 0 // (4) // this fails as consequence echo $fileSize . "\n"; echo fread($file, $fileSize); flock($file, LOCK_UN); fclose($file); Expected result: ---------------- should work as if the step (2) was commented out ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77595&edit=1

« previous php.bugs (#219475) next »