php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #49329 file_put_contents() Example #2 : FILE_APPEND and LOCK_EX are exclusive
Submitted: 2009-08-22 15:00 UTC Modified: 2009-09-07 06:37 UTC
From: contact at pascal-martin dot fr Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2009-08-22 15:00 UTC] contact at pascal-martin dot fr
Description:
------------
The documentation page of file_put_contents states that :

 * FILE_APPEND is mutually exclusive with LOCK_EX since appends are atomic and thus there is no reason to lock.
 * LOCK_EX is mutually exclusive with FILE_APPEND.

(It seems this is stated since bug #48522 has been corrected)

Still, the Example #2 given is like this :

<?php
$file = 'people.txt';
// The new person to add to the file
$person = "John Smith\n";
// Write the contents to the file, 
// using the FILE_APPEND flag to append the content to the end of the file
// and the LOCK_EX flag to prevent anyone else writing to the file at the same time
file_put_contents($file, $person, FILE_APPEND | LOCK_EX);
?>

If FILE_APPEND and LOCK_EX are exclusive, and "appends are atomic and thus there is no reason to lock", only the first one should be included in that example.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-07 06:36 UTC] svn@php.net
Automatic comment from SVN on behalf of torben
Revision: http://svn.php.net/viewvc/?view=revision&revision=288122
Log: Removed a redundant use of LOCK_EX with FILE_APPEND in an example.
Addresses bug #49329.
 [2009-09-07 06:37 UTC] torben@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [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&amp;revision=303153
Log: - Reversing changes from revisions 288122 and 282711, which addressed bug #49329 and bug #48522 (bogus bugs).
- Closes bug #52767.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 09 17:01:32 2024 UTC