|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61492 flock for php 5.3.2 - regression
Submitted: 2012-03-23 16:27 UTC Modified: 2013-01-09 01:59 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: spamik at yum dot pl Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.3.10 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
4 + 14 = ?
Subscribe to this entry?

 [2012-03-23 16:27 UTC] spamik at yum dot pl

"On versions of PHP before 5.3.2, the lock is released also by fclose() (which 
is also called automatically when script finished)."

This is huge regression. I've used with success file locking to check if another 
instance of file is already running putting code like this in front of the 
script or append_script

$h55 = fopen($_SERVER['argv'][0],"r");
while(!flock($h55, LOCK_EX + LOCK_NB )) {
echo "cant get lock, die\n";


$h55 = fopen($_SERVER['argv'][0],"r");
while(!flock($h55, LOCK_EX + LOCK_NB )) {
echo "cant get lock, waiting 10s\n";

I've used it for scripts that had variable running time with a crontab. Now it 
is all impossible thanks to that change :(


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-23 16:42 UTC] spamik at yum dot pl
"The automatic unlocking when the file's resource handle is closed was removed. 
Unlocking now always has to be done manually."
 [2012-03-26 00:43 UTC]
The manual sums this up: the behaviour was (intentionally) changed in 5.3.2, and 
isn't going to change again.
 [2012-03-26 00:43 UTC]
-Status: Open +Status: Not a bug -Type: Feature/Change Request +Type: Bug -Package: *General Issues +Package: Streams related
 [2013-01-09 01:59 UTC] spamik at yum dot pl
right, all changes are for the better...
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Sep 20 18:01:26 2020 UTC