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:13
Avg. Score:4.6 ± 0.6
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 10:01:32 2024 UTC