From: Marcus Boerger Date: Wed, 3 Sep 2003 16:13:40 +0000 (+0000) Subject: Fix static properties. X-Git-Tag: RELEASE_0_7~261 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b39a5aa2c97c679f1ffdaa8baa388d506e9aea7;p=php Fix static properties. # # There's only an errormessage missing which i'll wommit as soon as i find out # how to do it best. But besides that damn message everything works now and all # inheritance rules apply. # --- diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 4b3c938ff2..fdb2d6899a 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -700,7 +700,6 @@ ZEND_API int _object_and_properties_init(zval *arg, zend_class_entry *class_type if (!class_type->constants_updated) { zend_hash_apply_with_argument(&class_type->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); - zend_hash_apply_with_argument(class_type->static_members, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); class_type->constants_updated = 1; } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 122d64a7d1..988aa00c8d 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1768,7 +1768,12 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro mangle_property_name(&prot_name, &prot_name_length, "*", 1, child_info->name, child_info->name_length, ce->type & ZEND_INTERNAL_CLASS); if (child_info->flags & ZEND_ACC_STATIC) { - zend_hash_del(ce->static_members, prot_name, prot_name_length+1); + zval **prop; + if (zend_hash_find(parent_ce->static_members, prot_name, prot_name_length+1, (void**)&prop) == SUCCESS) { + (*prop)->refcount++; + zend_hash_update(ce->static_members, child_info->name, child_info->name_length+1, (void**)prop, sizeof(zval*), NULL); + zend_hash_del(ce->static_members, prot_name, prot_name_length+1); + } } else { zend_hash_del(&ce->default_properties, prot_name, prot_name_length+1); } @@ -1797,6 +1802,13 @@ ZEND_API void zend_do_inherit_interfaces(zend_class_entry *ce, zend_class_entry } +static void inherit_sttaic_prop(zval **p) +{ + (*p)->refcount++; + (*p)->is_ref = 1; +} + + void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce) { if ((ce->ce_flags & ZEND_ACC_INTERFACE) @@ -1813,10 +1825,9 @@ void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent_ce) /* Inherit properties */ zend_hash_merge(&ce->default_properties, &parent_ce->default_properties, (void (*)(void *)) zval_add_ref, NULL, sizeof(zval *), 0); + zend_hash_merge(ce->static_members, parent_ce->static_members, (void (*)(void *)) inherit_sttaic_prop, NULL, sizeof(zval *), 0); zend_hash_merge_ex(&ce->properties_info, &parent_ce->properties_info, (copy_ctor_func_t) (ce->type & ZEND_INTERNAL_CLASS ? zend_duplicate_property_info_internal : zend_duplicate_property_info), sizeof(zend_property_info), (merge_checker_func_t) do_inherit_property_access_check, ce); - /* STATIC_MEMBERS_FIXME */ -/* zend_hash_merge(ce->static_members, parent_ce->static_members, (void (*)(void *)) zval_add_ref, (void *) &tmp, sizeof(zval *), 0); */ zend_hash_merge(&ce->constants_table, &parent_ce->constants_table, (void (*)(void *)) zval_add_ref, NULL, sizeof(zval *), 0); zend_hash_merge_ex(&ce->function_table, &parent_ce->function_table, (copy_ctor_func_t) do_inherit_method, sizeof(zend_function), (merge_checker_func_t) do_inherit_method_check, ce); do_inherit_parent_constructor(ce); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index de31c1c89c..c7eccbf33b 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -722,7 +722,6 @@ static void zend_fetch_var_address(zend_op *opline, temp_variable *Ts, int type FREE_OP(Ts, &opline->op1, free_op1); break; case ZEND_FETCH_STATIC: - zval_update_constant(retval, (void *) 1 TSRMLS_CC); break; } } diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index a5914cbad9..3892918bf5 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -726,12 +726,7 @@ zval **zend_std_get_static_property(zend_class_entry *ce, char *property_name, i zend_error(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name, property_name); } - while (tmp_ce) { - if (zend_hash_quick_find(tmp_ce->static_members, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval)==SUCCESS) { - break; - } - tmp_ce = tmp_ce->parent; - } + zend_hash_quick_find(tmp_ce->static_members, property_info->name, property_info->name_length+1, property_info->h, (void **) &retval); if (!retval) { if (silent) { @@ -741,7 +736,6 @@ zval **zend_std_get_static_property(zend_class_entry *ce, char *property_name, i } } - zval_update_constant(retval, (void *) 1 TSRMLS_CC); return retval; }