Description
The following code:
<?php
$arquivo_lock = fopen("test.txt","a");
if (flock($arquivo_lock,LOCK_EX|LOCK_NB)) {
echo "Yes";
} else {
echo "No";
}
sleep(10);
fclose($arquivo_lock);
?>
Save the simple code above to the file test.php, for example. Now, in less than 10 seconds apart, open 2 (or more) tabs on your browser calling the file test.php and you will see every tab will show you Yes after some seconds. It should show Yes only on the first tab, all the other should return immediatly with No because I am using LOCK_NB flag.
This bug is pretty simple to reproduce and other people also confirmed it on Stackoverflow when I reported there.
PHP Version
8.x
Operating System
Confirmed at least on centos 9 stream and windows 11
Description
The following code:
Save the simple code above to the file
test.php, for example. Now, in less than 10 seconds apart, open 2 (or more) tabs on your browser calling the filetest.phpand you will see every tab will show youYesafter some seconds. It should showYesonly on the first tab, all the other should return immediatly withNobecause I am using LOCK_NB flag.This bug is pretty simple to reproduce and other people also confirmed it on Stackoverflow when I reported there.
PHP Version
8.x
Operating System
Confirmed at least on centos 9 stream and windows 11