diff options
| -rw-r--r-- | Zend/zend_API.c | 47 | ||||
| -rw-r--r-- | Zend/zend_API.h | 1 | ||||
| -rw-r--r-- | ext/reflection/php_reflection.c | 16 |
3 files changed, 23 insertions, 41 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 98312b3464..7e440eea1d 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -4049,42 +4049,37 @@ ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object } /* }}} */ -ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value) /* {{{ */ +ZEND_API int zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value) /* {{{ */ { zval *property; zend_class_entry *old_scope = EG(fake_scope); - zend_string *key = zend_string_init(name, name_length, 0); EG(fake_scope) = scope; - property = zend_std_get_static_property(scope, key, 0); + property = zend_std_get_static_property(scope, name, 0); EG(fake_scope) = old_scope; - zend_string_efree(key); + if (!property) { return FAILURE; - } else { - if (property != value) { - if (Z_ISREF_P(property)) { - zval_dtor(property); - ZVAL_COPY_VALUE(property, value); - if (Z_REFCOUNTED_P(value) && Z_REFCOUNT_P(value) > 0) { - zval_opt_copy_ctor(property); - } - } else { - zval garbage; + } - ZVAL_COPY_VALUE(&garbage, property); - if (Z_REFCOUNTED_P(value)) { - Z_ADDREF_P(value); - if (Z_ISREF_P(value)) { - SEPARATE_ZVAL(value); - } - } - ZVAL_COPY_VALUE(property, value); - zval_ptr_dtor(&garbage); - } - } - return SUCCESS; + if (property != value) { + zval garbage; + ZVAL_DEREF(property); + ZVAL_DEREF(value); + ZVAL_COPY_VALUE(&garbage, property); + ZVAL_COPY(property, value); + zval_ptr_dtor(&garbage); } + return SUCCESS; +} +/* }}} */ + +ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value) /* {{{ */ +{ + zend_string *key = zend_string_init(name, name_length, 0); + int retval = zend_update_static_property_ex(scope, key, value); + zend_string_efree(key); + return retval; } /* }}} */ diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 64a6bde19e..63c82a4b06 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -345,6 +345,7 @@ ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, size_t name_length, const char *value, size_t value_length); ZEND_API void zend_unset_property(zend_class_entry *scope, zval *object, const char *name, size_t name_length); +ZEND_API int zend_update_static_property_ex(zend_class_entry *scope, zend_string *name, zval *value); ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, size_t name_length, zval *value); ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, size_t name_length); ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, size_t name_length, zend_long value); diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index e7bfb272d5..4f46bd1ff8 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -5533,7 +5533,6 @@ ZEND_METHOD(reflection_property, setValue) { reflection_object *intern; property_reference *ref; - zval *variable_ptr; zval *object, *name; zval *value; zval *tmp; @@ -5549,26 +5548,13 @@ ZEND_METHOD(reflection_property, setValue) } 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; } } - 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_COPY_VALUE(&garbage, variable_ptr); - ZVAL_COPY(variable_ptr, value); - zval_ptr_dtor(&garbage); + zend_update_static_property_ex(ref->ce, ref->unmangled_name, value); } else { if (zend_parse_parameters(ZEND_NUM_ARGS(), "oz", &object, &value) == FAILURE) { return; |
