Fix bug #64782: SplFileObject constructor make $context optional
authorNikita Popov <nikic@php.net>
Thu, 12 Sep 2013 15:46:14 +0000 (17:46 +0200)
committerNikita Popov <nikic@php.net>
Thu, 12 Sep 2013 15:46:14 +0000 (17:46 +0200)
NEWS
ext/spl/spl_directory.c
ext/spl/tests/bug64782.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 22cd0120e5864215ca0c92034a4c5d9a1cbba95d..c907c1bc3015b1fa6782c335ea0b910723e63049 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -59,6 +59,10 @@ PHP                                                                        NEWS
   . Fixed bug #51127/#65359 Request #25630/#43980/#54383 (Added php_serialize 
     session serialize handler that uses plain serialize()). (Yasuo)
 
+- SPL:
+  . Fix bug #64782 (SplFileObject constructor make $context optional / give it
+    a default value). (Nikita)
+
 - Standard:
   . Fix issue with return types of password API helper functions. Found via static
     analysis by cjones. (Anthony Ferrara) 
index 1a417d0f5850af23b797cc0ef9ff99a7db6033e4..3dc7b7925c949441e30d232b8501dfcda44753cd 100644 (file)
@@ -2290,7 +2290,7 @@ SPL_METHOD(SplFileObject, __construct)
        intern->u.file.open_mode = NULL;
        intern->u.file.open_mode_len = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|sbr", 
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|sbr!", 
                        &intern->file_name, &intern->file_name_len,
                        &intern->u.file.open_mode, &intern->u.file.open_mode_len, 
                        &use_include_path, &intern->u.file.zcontext) == FAILURE) {              
diff --git a/ext/spl/tests/bug64782.phpt b/ext/spl/tests/bug64782.phpt
new file mode 100644 (file)
index 0000000..2b225cd
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Bug #64782: SplFileObject constructor make $context optional / give it a default value
+--FILE--
+<?php
+
+var_dump(new SplFileObject(__FILE__, "r", false, null));
+
+?>
+--EXPECTF--
+object(SplFileObject)#1 (%d) {
+  ["pathName":"SplFileInfo":private]=>
+  string(50) "%s/bug64782.php"
+  ["fileName":"SplFileInfo":private]=>
+  string(12) "bug64782.php"
+  ["openMode":"SplFileObject":private]=>
+  string(1) "r"
+  ["delimiter":"SplFileObject":private]=>
+  string(1) ","
+  ["enclosure":"SplFileObject":private]=>
+  string(1) """
+}