diff options
author | Marcus Boerger <helly@php.net> | 2006-07-10 00:18:53 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2006-07-10 00:18:53 +0000 |
commit | 71efa5b435f032b3a88204d8771b4f83869bec26 (patch) | |
tree | edc336dfa37e2e1df967a7a7c7390be036db2783 /ext/reflection/php_reflection.c | |
parent | c5ff44688a6ce84c09c80236a7e460913219eebe (diff) | |
download | php-git-71efa5b435f032b3a88204d8771b4f83869bec26.tar.gz |
- MFH Fixed bug #37816 (ReflectionProperty does not throw exception when accessing protected attribute)
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r-- | ext/reflection/php_reflection.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index a223889a68..de1b6435e9 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3838,23 +3838,24 @@ ZEND_METHOD(reflection_property, getValue) { reflection_object *intern; property_reference *ref; - zval *object; + zval *object, name; zval **member= NULL; METHOD_NOTSTATIC(reflection_property_ptr); GET_REFLECTION_OBJECT_PTR(ref); -#if MBO_0 if (!(ref->prop->flags & ZEND_ACC_PUBLIC)) { - _DO_THROW("Cannot access non-public member"); - /* Returns from this function */ + _default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC); + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name)); + zval_dtor(&name); + return; } -#endif if ((ref->prop->flags & ZEND_ACC_STATIC)) { zend_update_class_constants(intern->ce TSRMLS_CC); if (zend_hash_quick_find(CE_STATIC_MEMBERS(intern->ce), ref->prop->name, ref->prop->name_length + 1, ref->prop->h, (void **) &member) == FAILURE) { - zend_error(E_ERROR, "Internal error: Could not find the property %s", ref->prop->name); + zend_error(E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop->name); /* Bails out */ } } else { @@ -3862,7 +3863,7 @@ ZEND_METHOD(reflection_property, getValue) return; } if (zend_hash_quick_find(Z_OBJPROP_P(object), ref->prop->name, ref->prop->name_length + 1, ref->prop->h, (void **) &member) == FAILURE) { - zend_error(E_ERROR, "Internal error: Could not find the property %s", ref->prop->name); + zend_error(E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop->name); /* Bails out */ } } @@ -3880,7 +3881,7 @@ ZEND_METHOD(reflection_property, setValue) reflection_object *intern; property_reference *ref; zval **variable_ptr; - zval *object; + zval *object, name; zval *value; int setter_done = 0; zval *tmp; @@ -3890,8 +3891,11 @@ ZEND_METHOD(reflection_property, setValue) GET_REFLECTION_OBJECT_PTR(ref); if (!(ref->prop->flags & ZEND_ACC_PUBLIC)) { - _DO_THROW("Cannot access non-public member"); - /* Returns from this function */ + _default_get_entry(getThis(), "name", sizeof("name"), &name TSRMLS_CC); + zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, + "Cannot access non-public member %s::%s", intern->ce->name, Z_STRVAL(name)); + zval_dtor(&name); + return; } if ((ref->prop->flags & ZEND_ACC_STATIC)) { @@ -3910,7 +3914,7 @@ ZEND_METHOD(reflection_property, setValue) } if (zend_hash_quick_find(prop_table, ref->prop->name, ref->prop->name_length + 1, ref->prop->h, (void **) &variable_ptr) == FAILURE) { - zend_error(E_ERROR, "Internal error: Could not find the property %s", ref->prop->name); + zend_error(E_ERROR, "Internal error: Could not find the property %s::%s", intern->ce->name, ref->prop->name); /* Bails out */ } if (*variable_ptr == value) { |