Skip to content

Commit 9d530fe

Browse files
committed
discard -1
1 parent 3f0ddb8 commit 9d530fe

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

ext/standard/file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ PHP_MSHUTDOWN_FUNCTION(file) /* {{{ */
184184
static inline bool php_is_valid_flock_flag(zend_long s) {
185185
const zend_long sb = s & ~PHP_LOCK_NB;
186186
return (sb == PHP_LOCK_UN || sb == PHP_LOCK_SH ||
187-
sb == PHP_LOCK_EX || s == -1);
187+
sb == PHP_LOCK_EX);
188188
}
189189

190190
PHPAPI void php_flock_common(php_stream *stream, zend_long operation,

ext/standard/tests/file/flock.phpt

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ var_dump($would);
3131
var_dump(flock($fp, LOCK_UN, $would));
3232
var_dump($would);
3333

34-
var_dump(flock($fp, -1));
34+
try {
35+
var_dump(flock($fp, -1));
36+
} catch (\ValueError $e) {
37+
echo $e->getMessage() . \PHP_EOL;
38+
}
3539

3640
try {
3741
var_dump(flock($fp, 0));
@@ -59,5 +63,5 @@ bool(true)
5963
int(0)
6064
bool(true)
6165
int(0)
62-
bool(true)
66+
flock(): Argument #2 ($operation) must be one of LOCK_SH, LOCK_EX, or LOCK_UN
6367
flock(): Argument #2 ($operation) must be one of LOCK_SH, LOCK_EX, or LOCK_UN

0 commit comments

Comments
 (0)