Bug #79017 [NEW]: file_exists() return false on file flock()
From: asmanmmsj at gmail dot com
Operating system: windows
PHP version: 7.4.1
Package: *Directory/Filesystem functions
Bug Type: Bug
Bug description:file_exists() return false on file flock()
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:
--------------
-
--
Edit bug report at https://bugs.php.net/bug.php?id=79017&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79017&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79017&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79017&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79017&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79017&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79017&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79017&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79017&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79017&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79017&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79017&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79017&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79017&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79017&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79017&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79017&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79017&r=mysqlcfg
Thread (1 message)
- asmanmmsj at gmail dot com