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: 2021-08-02 12:53 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: cmb@php.net Assigned: cmb (profile)
Status: Duplicate Package: Filesystem function related
PHP Version: 7.1Git-2016-08-26 (Git) OS: *
Private report: No CVE-ID: None
 [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

Pull Requests

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
 [2021-08-02 12:53 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-08-02 12:53 UTC] cmb@php.net
This is actually a duplicate of bug #61201.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 17:01:32 2024 UTC