]> granicus.if.org Git - php/commitdiff
Fix #51374 (Wrongly initialized object properties)
authorEtienne Kneuss <colder@php.net>
Tue, 27 Apr 2010 05:58:39 +0000 (05:58 +0000)
committerEtienne Kneuss <colder@php.net>
Tue, 27 Apr 2010 05:58:39 +0000 (05:58 +0000)
NEWS
ext/spl/spl_directory.c
ext/spl/tests/bug51374.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 443094fc5d20dcb6467b7d905779aeb99afe11c0..9aeaebcbe8ea869f9276462561476a6e2a518aa0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -35,6 +35,7 @@ PHP                                                                        NEWS
 - Fixed bug #51445 (var_dump() invalid/slow *RECURSION* detection). (Felipe)
 - Fixed bug #51393 (DateTime::createFromFormat() fails if format string contains
   timezone). (Adam)
+- Fixed bug #51374 (Wrongly initialized object properties). (Etienne)
 - Fixed bug #51338 (URL-Rewriter is still enabled if use_only_cookies is
   on). (Ilia, j dot jeising at gmail dot com)
 - Fixed bug #51269 (zlib.output_compression Overwrites Vary Header). (Adam)
index a0a9251aa812eb79c1f0d9e6e407442939241f29..3ea16685bb42b04f01cd9914d163bdac54ee97f0 100755 (executable)
@@ -341,6 +341,9 @@ static spl_filesystem_object * spl_filesystem_object_create_info(spl_filesystem_
        php_set_error_handling(EH_THROW, spl_ce_RuntimeException TSRMLS_CC);
 
        ce = ce ? ce : source->info_class;
+
+       zend_update_class_constants(ce TSRMLS_CC);
+
        return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC);
        Z_TYPE_P(return_value) = IS_OBJECT;
 
@@ -381,6 +384,9 @@ static spl_filesystem_object * spl_filesystem_object_create_type(int ht, spl_fil
        switch (type) {
        case SPL_FS_INFO:
                ce = ce ? ce : source->info_class;
+
+               zend_update_class_constants(ce TSRMLS_CC);
+
                return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC);
                Z_TYPE_P(return_value) = IS_OBJECT;
 
@@ -399,6 +405,9 @@ static spl_filesystem_object * spl_filesystem_object_create_type(int ht, spl_fil
                break;
        case SPL_FS_FILE:
                ce = ce ? ce : source->file_class;
+
+               zend_update_class_constants(ce TSRMLS_CC);
+
                return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC);
                Z_TYPE_P(return_value) = IS_OBJECT;
        
diff --git a/ext/spl/tests/bug51374.phpt b/ext/spl/tests/bug51374.phpt
new file mode 100644 (file)
index 0000000..a4d2853
--- /dev/null
@@ -0,0 +1,19 @@
+--TEST--
+SPL: SplFileObject wrongly initializes objects
+--FILE--
+<?php
+class Foo extends SplFileObject
+{
+    public $bam = array();
+}
+$fileInfo = new SplFileInfo('php://temp');
+$fileInfo->setFileClass('Foo');
+$file = $fileInfo->openFile('r');
+
+print var_dump($file->bam); // is null or UNKNOWN:0
+?>
+===DONE===
+--EXPECT--
+array(0) {
+}
+===DONE===