mirror of
https://github.com/php/php-src.git
synced 2024-12-18 22:41:20 +08:00
Use Zend API helper functions
This commit is contained in:
parent
1cc0d78c9b
commit
83fe1f1cc8
@ -1174,31 +1174,10 @@ static void set_zval_property(zval* object, char* name, zval* val)
|
||||
static zval* get_zval_property(zval* object, char* name, zval *rv)
|
||||
{
|
||||
if (Z_TYPE_P(object) == IS_OBJECT) {
|
||||
zval member;
|
||||
zval *data;
|
||||
zend_class_entry *old_scope;
|
||||
|
||||
ZVAL_STRING(&member, name);
|
||||
old_scope = EG(fake_scope);
|
||||
EG(fake_scope) = Z_OBJCE_P(object);
|
||||
data = Z_OBJ_HT_P(object)->read_property(object, &member, BP_VAR_IS, NULL, rv);
|
||||
zval *data = zend_read_property(Z_OBJCE_P(object), object, name, strlen(name), 1, rv);
|
||||
if (data == &EG(uninitialized_zval)) {
|
||||
/* Hack for bug #32455 */
|
||||
zend_property_info *property_info;
|
||||
|
||||
property_info = zend_get_property_info(Z_OBJCE_P(object), Z_STR(member), 1);
|
||||
EG(fake_scope) = old_scope;
|
||||
if (property_info != ZEND_WRONG_PROPERTY_INFO && property_info &&
|
||||
zend_hash_exists(Z_OBJPROP_P(object), property_info->name)) {
|
||||
zval_ptr_dtor(&member);
|
||||
ZVAL_DEREF(data);
|
||||
return data;
|
||||
}
|
||||
zval_ptr_dtor(&member);
|
||||
return NULL;
|
||||
}
|
||||
zval_ptr_dtor(&member);
|
||||
EG(fake_scope) = old_scope;
|
||||
ZVAL_DEREF(data);
|
||||
return data;
|
||||
} else if (Z_TYPE_P(object) == IS_ARRAY) {
|
||||
@ -1210,15 +1189,7 @@ static zval* get_zval_property(zval* object, char* name, zval *rv)
|
||||
static void unset_zval_property(zval* object, char* name)
|
||||
{
|
||||
if (Z_TYPE_P(object) == IS_OBJECT) {
|
||||
zval member;
|
||||
zend_class_entry *old_scope;
|
||||
|
||||
ZVAL_STRING(&member, name);
|
||||
old_scope = EG(fake_scope);
|
||||
EG(fake_scope) = Z_OBJCE_P(object);
|
||||
Z_OBJ_HT_P(object)->unset_property(object, &member, NULL);
|
||||
EG(fake_scope) = old_scope;
|
||||
zval_ptr_dtor(&member);
|
||||
zend_unset_property(Z_OBJCE_P(object), object, name, strlen(name));
|
||||
} else if (Z_TYPE_P(object) == IS_ARRAY) {
|
||||
zend_hash_str_del(Z_ARRVAL_P(object), name, strlen(name));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user