php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #47115 Can't use flag LOCK_SH in file_get_contents
Submitted: 2009-01-15 15:32 UTC Modified: 2011-01-23 21:21 UTC
Votes:12
Avg. Score:4.8 ± 0.4
Reproduced:12 of 12 (100.0%)
Same Version:2 (16.7%)
Same OS:2 (16.7%)
From: marc dot bennewitz at giata dot de Assigned:
Status: Open Package: Filesystem function related
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marc dot bennewitz at giata dot de
New email:
PHP Version: OS:

 

 [2009-01-15 15:32 UTC] marc dot bennewitz at giata dot de
Description:
------------
similar to file_put_contents can use LOCK_EX


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-15 15:34 UTC] marc dot bennewitz at giata dot de
change subject: Can't use flag LOCK_SH in file_get_contents
 [2011-01-23 21:21 UTC] jani@php.net
-Package: Feature/Change Request +Package: Filesystem function related -Operating System: +Operating System: * -PHP Version: 6CVS-2009-01-15 (snap) +PHP Version: *
 [2014-04-06 03:42 UTC] php at richardneill dot org
Writing a file can be done in a single line, with file_put_contents().
Unfortunately, file_get_contents() and file() both need 5 lines to flock() - this is more complex than it needs to be, and asymmetrical wrt file_put_contents().

$fp = fopen ($DATA_FILE,"r");
flock ($fp, LOCK_SH);
$contents = file_get_contents($DATA_FILE);  
flock ($fp, LOCK_UN);
fclose ($fp);
 [2015-01-17 16:26 UTC] teo8976 at gmail dot com
How is it possible that this hasn't been addressed in 6 years??

This shouldn't even be marked as a feature request, this is a bug. A bug in the specifications, but still a bug. And a huge and obvious one.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC