summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2018-06-28 22:45:26 +0200
committerNikita Popov <nikita.ppv@gmail.com>2018-06-28 22:45:26 +0200
commitdb7ead0768076da486a9c98264061113233deb7f (patch)
tree3f5e620df92f7ddeea0260a5759c766331f549ea /ext/reflection/php_reflection.c
parente1e0176e68ffa1631f8ff791e9460d5ac6c0744e (diff)
downloadphp-git-db7ead0768076da486a9c98264061113233deb7f.tar.gz
Fix ReflectionProperty::get/setValue() on internal static property
This was broken by 6dc0cd868d972885249ce40f2d64097cd0ba6c1f, which moved static property initialization outside of constant updating. Instead of replicating logic, use zend_get_static_property() API in the reflection implementation, just like we're using read_property for non-static proprety access.
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r--ext/reflection/php_reflection.c53
1 files changed, 22 insertions, 31 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 861ee16e3e..6300e4a4e5 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -5495,18 +5495,16 @@ ZEND_METHOD(reflection_property, getValue)
return;
}
- if ((ref->prop.flags & ZEND_ACC_STATIC)) {
- if (UNEXPECTED(zend_update_class_constants(intern->ce) != SUCCESS)) {
- return;
- }
- if (Z_TYPE(CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) == IS_UNDEF) {
- zend_throw_error(NULL, "Internal error: Could not find the property %s::%s", ZSTR_VAL(intern->ce->name), ZSTR_VAL(ref->prop.name));
- return;
+ if (ref->prop.flags & ZEND_ACC_STATIC) {
+ zend_class_entry *old_scope = EG(fake_scope);
+ EG(fake_scope) = ref->ce;
+ member_p = zend_std_get_static_property(ref->ce, ref->unmangled_name, 0);
+ EG(fake_scope) = old_scope;
+
+ if (member_p) {
+ ZVAL_DEREF(member_p);
+ ZVAL_COPY(return_value, member_p);
}
- member_p = &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset];
- ZVAL_DEINDIRECT(member_p);
- ZVAL_DEREF(member_p);
- ZVAL_COPY(return_value, member_p);
} else {
zval rv;
@@ -5554,34 +5552,27 @@ ZEND_METHOD(reflection_property, setValue)
return;
}
- if ((ref->prop.flags & ZEND_ACC_STATIC)) {
+ if (ref->prop.flags & ZEND_ACC_STATIC) {
+ zend_class_entry *old_scope;
+ zval garbage;
+
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "z", &value) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &tmp, &value) == FAILURE) {
return;
}
}
- if (UNEXPECTED(zend_update_class_constants(intern->ce) != SUCCESS)) {
- return;
- }
- if (Z_TYPE(CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset]) == IS_UNDEF) {
- zend_throw_error(NULL, "Internal error: Could not find the property %s::%s", ZSTR_VAL(intern->ce->name), ZSTR_VAL(ref->prop.name));
- return;
- }
- variable_ptr = &CE_STATIC_MEMBERS(intern->ce)[ref->prop.offset];
- ZVAL_DEINDIRECT(variable_ptr);
- if (variable_ptr != value) {
- zval garbage;
+ old_scope = EG(fake_scope);
+ EG(fake_scope) = ref->ce;
+ variable_ptr = zend_std_get_static_property(ref->ce, ref->unmangled_name, 0);
+ EG(fake_scope) = old_scope;
- ZVAL_DEREF(variable_ptr);
- ZVAL_DEREF(value);
+ ZVAL_DEREF(variable_ptr);
+ ZVAL_DEREF(value);
- ZVAL_COPY_VALUE(&garbage, variable_ptr);
-
- ZVAL_COPY(variable_ptr, value);
-
- zval_ptr_dtor(&garbage);
- }
+ ZVAL_COPY_VALUE(&garbage, variable_ptr);
+ ZVAL_COPY(variable_ptr, value);
+ zval_ptr_dtor(&garbage);
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "oz", &object, &value) == FAILURE) {
return;