From: Marcus Boerger Date: Thu, 26 Feb 2004 01:06:18 +0000 (+0000) Subject: Fix problem with Reflection_Property (patch from Timm slightly modified). X-Git-Tag: RELEASE_0_2_0~152 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e1f3b2124a6ef21e32f73ae2c52c346cddab04d;p=php Fix problem with Reflection_Property (patch from Timm slightly modified). --- diff --git a/Zend/zend_reflection_api.c b/Zend/zend_reflection_api.c index 3bc7112b8b..0d4dd48eb9 100644 --- a/Zend/zend_reflection_api.c +++ b/Zend/zend_reflection_api.c @@ -771,7 +771,11 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info zend_class_entry *tmp_ce = ce->parent; zend_property_info *tmp_info; - while (tmp_ce && zend_hash_find(&ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) == SUCCESS) { + while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) == SUCCESS) { + if (tmp_info->flags & ZEND_ACC_PRIVATE) { + /* private in super class => NOT the same property */ + break; + } ce = tmp_ce; prop = tmp_info; tmp_ce = tmp_ce->parent; @@ -2564,20 +2568,25 @@ ZEND_METHOD(reflection_property, __construct) "Property %s::$%s does not exist", ce->name, name_str); return; } - free_alloca(lcname); if (!(property_info->flags & ZEND_ACC_PRIVATE)) { /* we have to seach the class hierarchy for this (implicit) public or protected property */ zend_class_entry *tmp_ce = ce->parent; zend_property_info *tmp_info; - while (tmp_ce && zend_hash_find(&ce->properties_info, name_str, name_len + 1, (void **) &tmp_info) == SUCCESS) { + while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, lcname, name_len + 1, (void **) &tmp_info) == SUCCESS) { + if (tmp_info->flags & ZEND_ACC_PRIVATE) { + /* private in super class => NOT the same property */ + break; + } ce = tmp_ce; property_info = tmp_info; tmp_ce = tmp_ce->parent; } } + free_alloca(lcname); + MAKE_STD_ZVAL(classname); ZVAL_STRINGL(classname, ce->name, ce->name_length, 1); zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 3bc7112b8b..0d4dd48eb9 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -771,7 +771,11 @@ static void reflection_property_factory(zend_class_entry *ce, zend_property_info zend_class_entry *tmp_ce = ce->parent; zend_property_info *tmp_info; - while (tmp_ce && zend_hash_find(&ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) == SUCCESS) { + while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, prop_name, strlen(prop_name) + 1, (void **) &tmp_info) == SUCCESS) { + if (tmp_info->flags & ZEND_ACC_PRIVATE) { + /* private in super class => NOT the same property */ + break; + } ce = tmp_ce; prop = tmp_info; tmp_ce = tmp_ce->parent; @@ -2564,20 +2568,25 @@ ZEND_METHOD(reflection_property, __construct) "Property %s::$%s does not exist", ce->name, name_str); return; } - free_alloca(lcname); if (!(property_info->flags & ZEND_ACC_PRIVATE)) { /* we have to seach the class hierarchy for this (implicit) public or protected property */ zend_class_entry *tmp_ce = ce->parent; zend_property_info *tmp_info; - while (tmp_ce && zend_hash_find(&ce->properties_info, name_str, name_len + 1, (void **) &tmp_info) == SUCCESS) { + while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, lcname, name_len + 1, (void **) &tmp_info) == SUCCESS) { + if (tmp_info->flags & ZEND_ACC_PRIVATE) { + /* private in super class => NOT the same property */ + break; + } ce = tmp_ce; property_info = tmp_info; tmp_ce = tmp_ce->parent; } } + free_alloca(lcname); + MAKE_STD_ZVAL(classname); ZVAL_STRINGL(classname, ce->name, ce->name_length, 1); zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL);