|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-12-23 10:24 UTC] cmb@php.net
-Summary: file_exists() return false on file flock()
+Summary: Can delete files in use by other processes
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
-PHP Version: 7.4.1
+PHP Version: 7.3.0
[2019-12-23 10:24 UTC] cmb@php.net
[2019-12-29 12:46 UTC] cmb@php.net
[2019-12-29 12:47 UTC] cmb@php.net
-Status: Verified
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2019-12-29 12:47 UTC] cmb@php.net
[2019-12-29 12:50 UTC] salathe@php.net
[2019-12-30 09:35 UTC] mumumu@php.net
[2020-02-07 06:04 UTC] phpdocbot@php.net
[2020-12-30 11:59 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 17:00:01 2025 UTC |
Description: ------------ hi file_exists() return false on locked file with flock()!! its ok on php 7.2 but after that its have problem... just run this test file 2 time in second time its not detect file exist because its locked with flock() Test script: --------------- <?php error_reporting(0); echo unlink("test.txt"); echo "<=unlink\r\n"; echo "\r\n>"; echo $exist = file_exists("test.txt");<<=== bug is here echo "<=exist\r\n"; if ($exist) { echo "!!!"; echo "\r\n"; sleep(1111); //exit(); } echo "\r\n>"; echo $file = fopen("test.txt","w+"); echo "<=fopn\r\n"; // exclusive lock echo "\r\n>"; echo $lockkk = flock($file,LOCK_EX); echo "<=lock\r\n"; if ($lockkk) { echo ">"; echo fwrite($file,"Add some text to the file."); echo "<=fwrite\r\n"; echo ">"; echo fflush($file); echo "<=fflush\r\n"; sleep(1000); // release lock flock($file,LOCK_UN); } else { echo "Error locking file!"; } echo "end:"; echo fclose($file); sleep(100); ?> Expected result: ---------------- fisrt run (and lock text.txt) sleep... result : ><=unlink ><=exist >Resource id #5<=fopn >1<=lock >26<=fwrite >1<=fflush second run (file already lock..) >1<=unlink ><=exist ><=fopn ><=lock Error locking file!end: OK result in php 7.2 : ><=unlink >1<=exist !!! Actual result: -------------- -