php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #81322 file_put_contents should support LOCK_NB
Submitted: 2021-08-02 12:46 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: divinity76 at gmail dot com Assigned:
Status: Open Package: *Directory/Filesystem functions
PHP Version: Next Minor Version OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: divinity76 at gmail dot com
New email:
PHP Version: OS:

 

 [2021-08-02 12:46 UTC] divinity76 at gmail dot com
Description:
------------
file_put_contents should support LOCK_NB just like it supports LOCK_EX.

luckily file_put_contents does not currently support any flags with the same value as LOCK_NB( LOCK_NB is 4 and FILE_USE_INCLUDE_PATH is 1 and FILE_APPEND is 8)

Test script:
---------------
<?php
$file=__FILE__;
$fp=fopen($file,"rb");
flock($fp,LOCK_EX);
var_dump(file_put_contents($file,"test",LOCK_EX|LOCK_NB));

Expected result:
----------------
bool(false) and perhaps some error about being unable to lock.

Actual result:
--------------
script hangs indefinitely, because file_put_contents doesn't understand LOCK_NB

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2024-07-17 06:55 UTC] katelyn2598shirley at gmail dot com
Thanks for making my work a lot easier. your post are appreciated. (https://github.com)(https://www.yourtexas-benefits.com)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 04:01:27 2024 UTC