php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79993 SplFileObject::flock has LOCK_NB as a valid operation
Submitted: 2020-08-18 21:04 UTC Modified: 2020-08-18 23:29 UTC
From: girgias@php.net Assigned: cmb (profile)
Status: Closed Package: SPL related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2020-08-18 21:04 UTC] girgias@php.net
Description:
------------
The documentation of SplFileObject::flock specifies that LOCK_NB is a valid operation whereas flock() says that one needs to add this option as a bitmask to the operation argument.

As SplFileObject::flock just calls PHP's normal flock function (or at least attempts to) we need to look at its implementation.

The behaviour of flock is correctly documented as one can see by the following implementation details (on master) [Note: PHP_LOCK_NB = 4] :

	/* flock_values contains all possible actions if (operation & 4) we won't block on the lock */
	act = flock_values[act - 1] | (operation & PHP_LOCK_NB ? LOCK_NB : 0);

And it warns/throw (on master) if passed on its own as can be seen:

	act = operation & 3;
	if (act < 1 || act > 3) {
		zend_argument_value_error(2, "must be either LOCK_SH, LOCK_EX, or LOCK_UN");
		RETURN_THROWS();
	}





Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-08-18 23:28 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=5236d760cea563c9f335947a2e511f75815f626b
Log: Fix #79993: SplFileObject::flock has LOCK_NB as a valid operation
 [2020-08-18 23:28 UTC] phpdocbot@php.net
-Status: Open +Status: Closed
 [2020-08-18 23:29 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-08-19 03:05 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=c919c778c33b5a542477dc3d6cf15b0f8823e514
Log: Fix #79993: SplFileObject::flock has LOCK_NB as a valid operation
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Dec 02 04:01:24 2020 UTC