php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72950 file_put_contents: LOCK_EX unsupported for userland stream wrappers
Submitted: 2016-08-26 16:36 UTC Modified: -
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: cmb@php.net Assigned:
Status: Open Package: Filesystem function related
PHP Version: 7.1Git-2016-08-26 (Git) OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-08-26 16:36 UTC] 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
"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-02 00:04 UTC] juliangut at gmail dot com
Using [vfsStream](https://github.com/mikey179/vfsStream) I get the same error (PHP 7.0.15)

Workaround: fopen/flock/fwrite/flock/fclose
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Mon Jul 16 10:01:53 2018 UTC