From: Andi Gutmans Date: Sat, 27 Jul 2002 15:53:14 +0000 (+0000) Subject: - Make sure classes are first looked for in the current scope. X-Git-Tag: dev~137 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b476ddf183aebfb32a4bb3f584c2749ff092635b;p=php - Make sure classes are first looked for in the current scope. - Make sure that during inheritance the global scope is searched if the - current one doesn't work. --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index bf072219c2..cc70bab015 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2066,7 +2066,8 @@ void zend_do_begin_class_declaration(znode *class_token, znode *class_name, znod CG(active_ce_parent_class_name).value.str.val = estrndup(parent_class_name->u.constant.value.str.val, parent_class_name->u.constant.value.str.len); CG(active_ce_parent_class_name).value.str.len = parent_class_name->u.constant.value.str.len; - if (zend_hash_find(CG(active_class_entry)?&CG(active_class_entry)->class_table:CG(class_table), parent_class_name->u.constant.value.str.val, parent_class_name->u.constant.value.str.len+1, (void **) &parent_class_p)==SUCCESS) { + if ((CG(active_class_entry) && (zend_hash_find(&CG(active_class_entry)->class_table, parent_class_name->u.constant.value.str.val, parent_class_name->u.constant.value.str.len+1, (void **) &parent_class_p) == SUCCESS)) || + zend_hash_find(CG(class_table), parent_class_name->u.constant.value.str.val, parent_class_name->u.constant.value.str.len+1, (void **) &parent_class_p) == SUCCESS) { parent_class = *parent_class_p; /* copy functions */ zend_hash_copy(&new_class_entry->function_table, &parent_class->function_table, (copy_ctor_func_t) function_add_ref, &tmp_zend_function, sizeof(zend_function)); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index efa5cafee9..426379bc22 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -645,6 +645,11 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry *** zval *retval_ptr; int retval; + if (EG(scope)) { + if (zend_hash_find(&EG(scope)->class_table, name, name_length+1, (void **) ce) == SUCCESS) { + return SUCCESS; + } + } if (zend_hash_find(EG(class_table), name, name_length+1, (void **) ce) == SUCCESS) { return SUCCESS; }