From: Andi Gutmans Date: Sun, 16 Jun 2002 18:25:05 +0000 (+0000) Subject: - Fix bug in class constants X-Git-Tag: php-4.3.0dev_zend2_alpha2~239 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=690c85b406559a823063c34fc0fc85bbe6a109dc;p=php - Fix bug in class constants - Start centralizing main class lookups. This will help implement - __autload() --- diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 5e85195630..70cff0085b 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1555,7 +1555,7 @@ binary_assign_op_addr_obj: { zval **value_ptr_ptr = get_zval_ptr_ptr(&EX(opline)->op2, EX(Ts), BP_VAR_W); - if (value_ptr_ptr = &EX(Ts)[EX(opline)->op2.u.var].var.ptr) { + if (value_ptr_ptr = EX(Ts)[EX(opline)->op2.u.var].var.ptr_ptr) { if (!(*value_ptr_ptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(*value_ptr_ptr) || (*value_ptr_ptr)->refcount == 1))) { zend_error(E_ERROR, "Can't assign by reference non-referencable value!"); @@ -1850,7 +1850,7 @@ binary_assign_op_addr_obj: class_name_strlen = tmp.value.str.len; } - if (zend_hash_find(EG(class_table), class_name_strval, class_name_strlen+1, (void **) &pce) == FAILURE) { + if (zend_lookup_class(class_name_strval, class_name_strlen, &pce TSRMLS_CC) == FAILURE) { zend_error(E_ERROR, "Class '%s' not found", class_name_strval); } else { EX(Ts)[EX(opline)->result.u.var].EA.class_entry = *pce; diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 686f1a6640..e578842231 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -64,7 +64,7 @@ static inline void safe_free_zval_ptr(zval *p) FREE_ZVAL(p); } } - +ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC); ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC); static inline int i_zend_is_true(zval *op) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index c007ee8bb5..36596e0228 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -331,12 +331,12 @@ ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC) if (strchr(p->value.str.val, ':')) { char *cur, *temp; char *last; - zend_class_entry *ce; + zend_class_entry **ce; zval **value; last = tsrm_strtok_r(p->value.str.val, ":", &temp); - if (zend_hash_find(EG(class_table), last, strlen(last)+1, (void **)&ce) == FAILURE) { + if (zend_lookup_class(last, strlen(last), &ce TSRMLS_CC) == FAILURE) { zend_error(E_ERROR, "Invalid class! Improve this error message"); } @@ -347,12 +347,12 @@ ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC) if (!cur) { break; } - if (zend_hash_find(&ce->class_table, last, strlen(last)+1, (void **)&ce) == FAILURE) { + if (zend_hash_find(&(*ce)->class_table, last, strlen(last)+1, (void **)&ce) == FAILURE) { zend_error(E_ERROR, "Invalid class! Improve this error message"); } last = cur; } - if (zend_hash_find(&ce->constants_table, last, strlen(last)+1, (void **) &value) == FAILURE) { + if (zend_hash_find(&(*ce)->constants_table, last, strlen(last)+1, (void **) &value) == FAILURE) { zend_error(E_ERROR, "Invalid class! Improve this error message"); } const_value = **value; @@ -500,7 +500,7 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun lc_class = estrndup(Z_STRVAL_PP(object_pp), Z_STRLEN_PP(object_pp)); zend_str_tolower(lc_class, Z_STRLEN_PP(object_pp)); - found = zend_hash_find(EG(class_table), lc_class, Z_STRLEN_PP(object_pp) + 1, (void **) &ce); + found = zend_lookup_class(lc_class, Z_STRLEN_PP(object_pp), &ce TSRMLS_CC); efree(lc_class); if (found == FAILURE) return FAILURE; @@ -637,6 +637,11 @@ int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *fun return SUCCESS; } +ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC) +{ + return zend_hash_find(EG(class_table), name, name_length+1, (void **) ce); +} + ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC) {