]> granicus.if.org Git - php/commitdiff
- Error out if get_method() isn't defined.
authorAndi Gutmans <andi@php.net>
Tue, 16 Mar 2004 14:39:07 +0000 (14:39 +0000)
committerAndi Gutmans <andi@php.net>
Tue, 16 Mar 2004 14:39:07 +0000 (14:39 +0000)
- Use calling scope of internal function callee when calling a method
  using static syntax (array("A", "func"));

Zend/zend_execute.c
Zend/zend_execute_API.c

index c914f1fd73742a12d2a0a4d89f0d62ed2c70e79a..264002fc54c2be86e14ce33c895efb710d94f058 100644 (file)
@@ -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)) {
index 7f4b1f7f33492cc9dbb93ee4539a0ab23964d860..937d7fad8bda7417bd725a95cfdec587ca206250 100644 (file)
@@ -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) {