Bug #72950 [Com]: file_put_contents: LOCK_EX unsupported for userland stream wrappers
| From: | juliangut at gmail dot com | Date: | Thu, 02 Mar 2017 00:04:38 +0000 |
| Subject: | Bug #72950 [Com]: file_put_contents: LOCK_EX unsupported for userland stream wrappers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207650@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72950&edit=1
ID: 72950
Comment by: juliangut at gmail dot com
Reported by: cmb@php.net
Summary: file_put_contents: LOCK_EX unsupported for userland
stream wrappers
Status: Open
Type: Bug
Package: Filesystem function related
Operating System: *
PHP Version: 7.1Git-2016-08-26 (Git)
Block user comment: N
Private report: N
New Comment:
Using [vfsStream](https://github.com/mikey179/vfsStream) I get the same error (PHP 7.0.15)
Workaround: fopen/flock/fwrite/flock/fclose
Previous Comments:
------------------------------------------------------------------------
[2016-08-26 16:36:37] cmb@php.net
Description:
------------
When the LOCK_EX flag is passed to file_put_contents() with a
userland stream wrapper URL that supports locking, the function
fails.
This bug has been introduced with commit 17d22a5[1] to fix
bug #44501.
[1] <https://github.com/php/php-src/commit/17d22a5>
Test script:
---------------
See <https://gist.github.com/cmb69/c3492b5f3c827edbe656eac215b1fad0>.
Expected result:
----------------
bool(true)
line1
line2
line3
string(18) "line1
line2
line3
"
string(3) "foo"
Actual result:
--------------
bool(true)
line1
line2
line3
string(18) "line1
line2
line3
"
Warning: file_put_contents(): Exclusive locks may only be set for regular files in
/vagrant/varstream.php on line 118
string(18) "line1
line2
line3
"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72950&edit=1