Req #47115 [Com]: Can't use flag LOCK_SH in file_get_contents
| From: | teo8976 at gmail dot com | Date: | Sat, 17 Jan 2015 16:26:19 +0000 |
| Subject: | Req #47115 [Com]: Can't use flag LOCK_SH in file_get_contents | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-190003@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=47115&edit=1
ID: 47115
Comment by: teo8976 at gmail dot com
Reported by: marc dot bennewitz at giata dot de
Summary: Can't use flag LOCK_SH in file_get_contents
Status: Open
Type: Feature/Change Request
Package: Filesystem function related
Operating System: *
PHP Version: *
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2014-04-06 03:42:52] 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);
------------------------------------------------------------------------
[2009-01-15 15:34:09] marc dot bennewitz at giata dot de
change subject: Can't use flag LOCK_SH in file_get_contents
------------------------------------------------------------------------
[2009-01-15 15:32:14] marc dot bennewitz at giata dot de
Description:
------------
similar to file_put_contents can use LOCK_EX
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=47115&edit=1