From: Andi Gutmans Date: Tue, 16 Mar 2004 14:39:07 +0000 (+0000) Subject: - Error out if get_method() isn't defined. X-Git-Tag: php-5.0.0RC1RC2~33 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0041aff953074b11c9135c6032be39504d62e53d;p=php - Error out if get_method() isn't defined. - Use calling scope of internal function callee when calling a method using static syntax (array("A", "func")); --- diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index c914f1fd73..264002fc54 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -2453,6 +2453,10 @@ int zend_init_method_call_handler(ZEND_OPCODE_HANDLER_ARGS) EX(object) = get_obj_zval_ptr(&opline->op1, EX(Ts), &EG(free_op1), BP_VAR_R TSRMLS_CC); if (EX(object) && EX(object)->type == IS_OBJECT) { + if (Z_OBJ_HT_P(EX(object))->get_method == NULL) { + zend_error(E_ERROR, "Object does not support method calls"); + } + /* First, locate the function. */ EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(EX(object), function_name_strval, function_name_strlen TSRMLS_CC); if (!EX(fbc)) { diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 7f4b1f7f33..937d7fad8b 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -645,25 +645,18 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS fci->object_pp = EG(This)?&EG(This):NULL; } else { zend_class_entry *scope; - int in_autoload = EG(in_autoload); - EG(in_autoload) = 0; scope = EG(active_op_array)->scope; found = zend_lookup_class(Z_STRVAL_PP(fci->object_pp), Z_STRLEN_PP(fci->object_pp), &ce TSRMLS_CC); if (found == FAILURE) { - EG(in_autoload) = in_autoload; zend_error(E_ERROR, "Class '%s' not found", Z_STRVAL_PP(fci->object_pp)); } - EG(in_autoload) = in_autoload; - fci->object_pp = NULL; - if (EG(This)) { - while (scope != NULL) { - if (scope == *ce) { - fci->object_pp = &EG(This); - break; - } - scope = scope->parent; - } + if (EG(This) && + instanceof_function(Z_OBJCE_P(EG(This)), scope) && + instanceof_function(scope, *ce)) { + fci->object_pp = &EG(This); + } else { + fci->object_pp = NULL; } } if (found == FAILURE) @@ -683,6 +676,9 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS } if (fci->object_pp) { + if (Z_OBJ_HT_PP(fci->object_pp)->get_method == NULL) { + zend_error(E_ERROR, "Object does not support method calls"); + } EX(function_state).function = Z_OBJ_HT_PP(fci->object_pp)->get_method(*fci->object_pp, Z_STRVAL_P(fci->function_name), Z_STRLEN_P(fci->function_name) TSRMLS_CC); } else if (calling_scope) {