php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #52767 Invalid doc of FILE_APPEND|LOCK_EX for file_put_contents caused by #48522
Submitted: 2010-09-02 20:15 UTC Modified: 2010-09-08 02:18 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: andrzeje at wit dot edu dot pl Assigned: cataphract (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.3 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrzeje at wit dot edu dot pl
New email:
PHP Version: OS:

 

 [2010-09-02 20:15 UTC] andrzeje at wit dot edu dot pl
Description:
------------
In bug report #48522 gwynne@php.net said:
------
php-5.3/ext/standard/file.c:614
	if (flags & PHP_FILE_APPEND) {
		mode[0] = 'a';
	} else if (flags & LOCK_EX) {

Obviously FILE_APPEND and LOCK_EX are mutually exclusive. This is not documented!
------

OBVIOUSLY someone forget to check what is few lines below:
---BEGIN CODE---
	if (flags & LOCK_EX && (!php_stream_supports_lock(stream) || php_stream_lock(stream, LOCK_EX))) {
----END CODE----
It seems that `LOCK_EX` check is independent of `FILE_APPEND`. However the docs were "fixed" and now they're telling that `LOCK_EX` and `FILE_APPEND` are mutually exclusive.

Test script:
---------------
---
From manual page: function.file-put-contents
---


Expected result:
----------------
... It's a documentation bug.

Actual result:
--------------
Once again I say... it's a DOCS bug!


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-08 02:17 UTC] cataphract@php.net
Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&revision=303153
Log: - Reversing changes from revisions 288122 and 282711, which addressed bug #49329 and bug #48522 (bogus bugs).
- Closes bug #52767.
 [2010-09-08 02:18 UTC] cataphract@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cataphract
 [2010-09-08 02:18 UTC] cataphract@php.net
Reverses changes made in response to bogus bug #49329 and bogus bug #48522.
 [2016-01-26 22:46 UTC] tito dot bouzout at gmail dot com
I'm confused, can you please clarify if doing 
file_put_contents($file, $person, FILE_APPEND);
will lock the file for appending, or we need to do 
file_put_contents($file, $person, FILE_APPEND | LOCK_EX);
if we need to do the last one then please update the docs because now are giving wrong information as reported in the other bugs mentioned here. 
http://php.net/file-put-contents
 [2023-01-23 08:10 UTC] patric908 at gmail dot com
(https://forum.codeigniter.com/member.php?action=profile&uid=65916)github.com
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jan 20 11:01:31 2025 UTC