felipe Sat, 20 Nov 2010 22:53:55 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=305589
Log: - Fixed bug #53366 (Reflection doesnt get dynamic property value from getProperty()) Bug: http://bugs.php.net/53366 (Open) Reflection doesnt get dynamic property value from getProperty() Changed paths: U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/reflection/php_reflection.c A php/php-src/branches/PHP_5_3/ext/reflection/tests/bug53366.phpt U php/php-src/trunk/ext/reflection/php_reflection.c A php/php-src/trunk/ext/reflection/tests/bug53366.phpt Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2010-11-20 22:34:34 UTC (rev 305588) +++ php/php-src/branches/PHP_5_3/NEWS 2010-11-20 22:53:55 UTC (rev 305589) @@ -7,6 +7,8 @@ EXTR_OVERWRITE. (jorto at redhat dot com) - Fixed crashes on invalid parameters in intl extension (Stas, Maksymilian Arciemowicz) +- Fixed bug #53366 (Reflection doesnt get dynamic property value from + getProperty()). (Felipe) - Fixed bug #53362 (Segmentation fault when extending SplFixedArray). (Felipe) - Fixed bug #50987 (unaligned memory access in phar.c). (geissert at debian dot org, Ilia) Modified: php/php-src/branches/PHP_5_3/ext/reflection/php_reflection.c =================================================================== --- php/php-src/branches/PHP_5_3/ext/reflection/php_reflection.c 2010-11-20 22:34:34 UTC (rev 305588) +++ php/php-src/branches/PHP_5_3/ext/reflection/php_reflection.c 2010-11-20 22:53:55 UTC (rev 305589) @@ -190,7 +190,8 @@ REF_TYPE_OTHER, /* Must be 0 */ REF_TYPE_FUNCTION, REF_TYPE_PARAMETER, - REF_TYPE_PROPERTY + REF_TYPE_PROPERTY, + REF_TYPE_DYNAMIC_PROPERTY } reflection_type_t; /* Struct for reflection objects */ @@ -272,6 +273,7 @@ { reflection_object *intern = (reflection_object *) object; parameter_reference *reference; + property_reference *prop_reference; if (intern->ptr) { switch (intern->ref_type) { @@ -286,6 +288,11 @@ case REF_TYPE_PROPERTY: efree(intern->ptr); break; + case REF_TYPE_DYNAMIC_PROPERTY: + prop_reference = (property_reference*)intern->ptr; + efree(prop_reference->prop.name); + efree(intern->ptr); + break; case REF_TYPE_OTHER: break; } @@ -3583,13 +3590,15 @@ if (zend_hash_exists(Z_OBJ_HT_P(intern->obj)->get_properties(intern->obj TSRMLS_CC), name, name_len+1)) { zend_property_info property_info_tmp; property_info_tmp.flags = ZEND_ACC_IMPLICIT_PUBLIC; - property_info_tmp.name = name; + property_info_tmp.name = estrndup(name, name_len); property_info_tmp.name_length = name_len; property_info_tmp.h = zend_get_hash_value(name, name_len+1); property_info_tmp.doc_comment = NULL; property_info_tmp.ce = ce; reflection_property_factory(ce, &property_info_tmp, return_value TSRMLS_CC); + intern = (reflection_object *) zend_object_store_get_object(return_value TSRMLS_CC); + intern->ref_type = REF_TYPE_DYNAMIC_PROPERTY; return; } } Added: php/php-src/branches/PHP_5_3/ext/reflection/tests/bug53366.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/reflection/tests/bug53366.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/reflection/tests/bug53366.phpt 2010-11-20 22:53:55 UTC (rev 305589) @@ -0,0 +1,25 @@ +--TEST-- +Bug #53366 (Reflection doesnt get dynamic property value from getProperty()) +--FILE-- +<?php + +class UserClass { +} + +$myClass = new UserClass; +$myClass->id = 1000; + +$reflect = new ReflectionObject($myClass); + +var_dump($reflect->getProperty('id')); +var_dump($reflect->getProperty('id')->getValue($myClass)); + +?> +--EXPECTF-- +object(ReflectionProperty)#%d (2) { + ["name"]=> + string(2) "id" + ["class"]=> + string(9) "UserClass" +} +int(1000) Property changes on: php/php-src/branches/PHP_5_3/ext/reflection/tests/bug53366.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Modified: php/php-src/trunk/ext/reflection/php_reflection.c =================================================================== --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-11-20 22:34:34 UTC (rev 305588) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-11-20 22:53:55 UTC (rev 305589) @@ -198,7 +198,8 @@ REF_TYPE_OTHER, /* Must be 0 */ REF_TYPE_FUNCTION, REF_TYPE_PARAMETER, - REF_TYPE_PROPERTY + REF_TYPE_PROPERTY, + REF_TYPE_DYNAMIC_PROPERTY } reflection_type_t; /* Struct for reflection objects */ @@ -284,6 +285,7 @@ { reflection_object *intern = (reflection_object *) object; parameter_reference *reference; + property_reference *prop_reference; if (intern->ptr) { switch (intern->ref_type) { @@ -298,6 +300,11 @@ case REF_TYPE_PROPERTY: efree(intern->ptr); break; + case REF_TYPE_DYNAMIC_PROPERTY: + prop_reference = (property_reference*)intern->ptr; + efree(prop_reference->prop.name); + efree(intern->ptr); + break; case REF_TYPE_OTHER: break; } @@ -3825,13 +3832,15 @@ if (zend_hash_exists(Z_OBJ_HT_P(intern->obj)->get_properties(intern->obj TSRMLS_CC), name, name_len+1)) { zend_property_info property_info_tmp; property_info_tmp.flags = ZEND_ACC_IMPLICIT_PUBLIC; - property_info_tmp.name = name; + property_info_tmp.name = estrndup(name, name_len); property_info_tmp.name_length = name_len; property_info_tmp.h = zend_get_hash_value(name, name_len+1); property_info_tmp.doc_comment = NULL; property_info_tmp.ce = ce; reflection_property_factory(ce, &property_info_tmp, return_value TSRMLS_CC); + intern = (reflection_object *) zend_object_store_get_object(return_value TSRMLS_CC); + intern->ref_type = REF_TYPE_DYNAMIC_PROPERTY; return; } } Added: php/php-src/trunk/ext/reflection/tests/bug53366.phpt =================================================================== --- php/php-src/trunk/ext/reflection/tests/bug53366.phpt (rev 0) +++ php/php-src/trunk/ext/reflection/tests/bug53366.phpt 2010-11-20 22:53:55 UTC (rev 305589) @@ -0,0 +1,25 @@ +--TEST-- +Bug #53366 (Reflection doesnt get dynamic property value from getProperty()) +--FILE-- +<?php + +class UserClass { +} + +$myClass = new UserClass; +$myClass->id = 1000; + +$reflect = new ReflectionObject($myClass); + +var_dump($reflect->getProperty('id')); +var_dump($reflect->getProperty('id')->getValue($myClass)); + +?> +--EXPECTF-- +object(ReflectionProperty)#%d (2) { + ["name"]=> + string(2) "id" + ["class"]=> + string(9) "UserClass" +} +int(1000) Property changes on: php/php-src/trunk/ext/reflection/tests/bug53366.phpt ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php