cvs: php-src(PHP_5_2) / NEWS /ext/reflection php_reflection.c /ext/reflection/tests bug40431.phpt

From: Date: Sat, 10 Feb 2007 20:52:42 +0000
Subject: cvs: php-src(PHP_5_2) / NEWS /ext/reflection php_reflection.c /ext/reflection/tests bug40431.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-43001@lists.php.net to get a copy of this message
tony2001 Sat Feb 10 20:52:42 2007 UTC Added files: (Branch: PHP_5_2) /php-src/ext/reflection/tests bug40431.phpt Modified files: /php-src NEWS /php-src/ext/reflection php_reflection.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.528&r2=1.2027.2.547.2.529&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.528 php-src/NEWS:1.2027.2.547.2.529 --- php-src/NEWS:1.2027.2.547.2.528 Fri Feb 9 19:48:46 2007 +++ php-src/NEWS Sat Feb 10 20:52:42 2007 @@ -4,6 +4,8 @@ - Upgraded SQLite 3 to version 3.3.12 (Ilia) - Upgraded PCRE to version 7.0 (Nuno) - Add --ri switch to CLI which allows to check extension information. (Marcus) +- Fixed bug #40431 (dynamic properties may cause crash in ReflectionProperty + methods). (Tony) - Fixed bug #40410 (ext/posix does not compile on MacOS 10.3.9). (Tony) - Fixed bug #39836 (SplObjectStorage empty after unserialize). (Marcus) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.33&r2=1.164.2.33.2.34&diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.164.2.33.2.33 php-src/ext/reflection/php_reflection.c:1.164.2.33.2.34 --- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.33 Mon Jan 1 09:36:05 2007 +++ php-src/ext/reflection/php_reflection.c Sat Feb 10 20:52:42 2007 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reflection.c,v 1.164.2.33.2.33 2007/01/01 09:36:05 sebastian Exp $ */ +/* $Id: php_reflection.c,v 1.164.2.33.2.34 2007/02/10 20:52:42 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1142,14 +1142,19 @@ if (!(prop->flags & ZEND_ACC_PRIVATE)) { /* we have to search the class hierarchy for this (implicit) public or protected property */ - zend_class_entry *tmp_ce = ce; - zend_property_info *tmp_info; - + zend_class_entry *tmp_ce = ce, *store_ce = ce; + zend_property_info *tmp_info = NULL; + while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) != SUCCESS) { ce = tmp_ce; - prop = tmp_info; tmp_ce = tmp_ce->parent; } + + if (tmp_info && !(tmp_info->flags & ZEND_ACC_SHADOW)) { /* found something and it's not a parent's private */ + prop = tmp_info; + } else { /* not found, use initial value */ + ce = store_ce; + } } MAKE_STD_ZVAL(name); @@ -4884,7 +4889,7 @@ php_info_print_table_start(); php_info_print_table_header(2, "Reflection", "enabled"); - php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.164.2.33.2.33 2007/01/01 09:36:05 sebastian Exp $"); + php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.164.2.33.2.34 2007/02/10 20:52:42 tony2001 Exp $"); php_info_print_table_end(); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/bug40431.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/bug40431.phpt +++ php-src/ext/reflection/tests/bug40431.phpt --TEST-- Bug #40431 (dynamic properties may cause crash in ReflectionProperty methods) --FILE-- <?php echo "=== 1st test ===\n"; $Obj->value = 'value'; $RefObj = new ReflectionObject($Obj); $props = $RefObj->getProperties(); var_dump($props); var_dump($props[0]->isStatic()); var_dump($props[0]->isPrivate()); var_dump($props[0]->isPublic()); var_dump($props[0]->isProtected()); echo "=== 2nd test ===\n"; class test1 { } class test2 extends test1{ } $Obj = new test2; $Obj->value = 'value'; $RefObj = new ReflectionObject($Obj); $props = $RefObj->getProperties(); var_dump($props); var_dump($props[0]->isStatic()); var_dump($props[0]->isPrivate()); var_dump($props[0]->isPublic()); var_dump($props[0]->isProtected()); echo "=== 3rd test ===\n"; class test3 { } $Obj = new test3; $Obj->value = 'value'; $RefObj = new ReflectionObject($Obj); $props = $RefObj->getProperties(); var_dump($props); var_dump($props[0]->isStatic()); var_dump($props[0]->isPrivate()); var_dump($props[0]->isPublic()); var_dump($props[0]->isProtected()); echo "=== 4th test ===\n"; class test5 { private $value = 1; } class test4 extends test5{ } $Obj = new test4; $Obj->value = 'value'; $RefObj = new ReflectionObject($Obj); $props = $RefObj->getProperties(); var_dump($props); var_dump($props[0]->isStatic()); var_dump($props[0]->isPrivate()); var_dump($props[0]->isPublic()); var_dump($props[0]->isProtected()); echo "Done\n"; ?> --EXPECTF-- === 1st test === Strict Standards: Creating default object from empty value in %s on line %d array(1) { [0]=> &object(ReflectionProperty)#%d (2) { ["name"]=> string(5) "value" ["class"]=> string(8) "stdClass" } } bool(false) bool(false) bool(true) bool(false) === 2nd test === array(1) { [0]=> &object(ReflectionProperty)#%d (2) { ["name"]=> string(5) "value" ["class"]=> string(5) "test2" } } bool(false) bool(false) bool(true) bool(false) === 3rd test === array(1) { [0]=> &object(ReflectionProperty)#%d (2) { ["name"]=> string(5) "value" ["class"]=> string(5) "test3" } } bool(false) bool(false) bool(true) bool(false) === 4th test === array(1) { [0]=> &object(ReflectionProperty)#%d (2) { ["name"]=> string(5) "value" ["class"]=> string(5) "test4" } } bool(false) bool(false) bool(true) bool(false) Done --UEXPECTF-- === 1st test === Strict Standards: Creating default object from empty value in %s on line %d array(1) { [0]=> &object(ReflectionProperty)#%d (2) { [u"name"]=> unicode(5) "value" [u"class"]=> unicode(8) "stdClass" } } bool(false) bool(false) bool(true) bool(false) === 2nd test === array(1) { [0]=> &object(ReflectionProperty)#%d (2) { [u"name"]=> unicode(5) "value" [u"class"]=> unicode(5) "test2" } } bool(false) bool(false) bool(true) bool(false) === 3rd test === array(1) { [0]=> &object(ReflectionProperty)#%d (2) { [u"name"]=> unicode(5) "value" [u"class"]=> unicode(5) "test3" } } bool(false) bool(false) bool(true) bool(false) === 4th test === array(1) { [0]=> &object(ReflectionProperty)#%d (2) { [u"name"]=> unicode(5) "value" [u"class"]=> unicode(5) "test4" } } bool(false) bool(false) bool(true) bool(false) Done

« previous php.cvs (#43001) next »