Skip to content

Commit ad976d8

Browse files
committed
Fix bug #64782: SplFileObject constructor make $context optional
1 parent 165f544 commit ad976d8

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ PHP NEWS
5959
. Fixed bug #51127/#65359 Request #25630/#43980/#54383 (Added php_serialize
6060
session serialize handler that uses plain serialize()). (Yasuo)
6161

62+
- SPL:
63+
. Fix bug #64782 (SplFileObject constructor make $context optional / give it
64+
a default value). (Nikita)
65+
6266
- Standard:
6367
. Fix issue with return types of password API helper functions. Found via static
6468
analysis by cjones. (Anthony Ferrara)

ext/spl/spl_directory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,7 @@ SPL_METHOD(SplFileObject, __construct)
22902290
intern->u.file.open_mode = NULL;
22912291
intern->u.file.open_mode_len = 0;
22922292

2293-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|sbr",
2293+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|sbr!",
22942294
&intern->file_name, &intern->file_name_len,
22952295
&intern->u.file.open_mode, &intern->u.file.open_mode_len,
22962296
&use_include_path, &intern->u.file.zcontext) == FAILURE) {

ext/spl/tests/bug64782.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #64782: SplFileObject constructor make $context optional / give it a default value
3+
--FILE--
4+
<?php
5+
6+
var_dump(new SplFileObject(__FILE__, "r", false, null));
7+
8+
?>
9+
--EXPECTF--
10+
object(SplFileObject)#1 (%d) {
11+
["pathName":"SplFileInfo":private]=>
12+
string(50) "%s/bug64782.php"
13+
["fileName":"SplFileInfo":private]=>
14+
string(12) "bug64782.php"
15+
["openMode":"SplFileObject":private]=>
16+
string(1) "r"
17+
["delimiter":"SplFileObject":private]=>
18+
string(1) ","
19+
["enclosure":"SplFileObject":private]=>
20+
string(1) """
21+
}

0 commit comments

Comments
 (0)