]> granicus.if.org Git - php/commitdiff
- Fixed bug #45186 (__call depends on __callstatic in class scope)
authorFelipe Pena <felipe@php.net>
Thu, 5 Jun 2008 18:53:06 +0000 (18:53 +0000)
committerFelipe Pena <felipe@php.net>
Thu, 5 Jun 2008 18:53:06 +0000 (18:53 +0000)
Zend/zend_API.c

index 163ec5411c82e8b784fa752e7f931cfcea631d7f..d8f627adad7b375001844a6427331ad13e3a00bb 100644 (file)
@@ -2392,14 +2392,27 @@ static int zend_is_callable_check_func(int check_flags, zval ***zobj_ptr_ptr, ze
                if (*zobj_ptr_ptr && *ce_ptr && (*ce_ptr)->__call != 0) {
                        retval = (*ce_ptr)->__call != NULL;
                        *fptr_ptr = (*ce_ptr)->__call;
-               } else if (!*zobj_ptr_ptr && *ce_ptr && (*ce_ptr)->__callstatic) {
-                       retval = 1;
-                       *fptr_ptr = (*ce_ptr)->__callstatic;
                } else {
-                       if (*ce_ptr) {
-                               if (error) zend_spprintf(error, 0, "class '%s' does not have a method '%s'", (*ce_ptr)->name, lmname);
-                       } else {
-                               if (error) zend_spprintf(error, 0, "function '%s' does not exist", lmname);
+                       if (!*zobj_ptr_ptr && *ce_ptr && ((*ce_ptr)->__callstatic || (*ce_ptr)->__call)) {
+                               if ((*ce_ptr)->__call &&
+                                       EG(This) &&
+                               Z_OBJ_HT_P(EG(This))->get_class_entry &&
+                               instanceof_function(Z_OBJCE_P(EG(This)), *ce_ptr TSRMLS_CC)) {
+                                       retval = 1;
+                                       *fptr_ptr = (*ce_ptr)->__call;
+                                       *zobj_ptr_ptr = &EG(This);
+                               } else if ((*ce_ptr)->__callstatic) {
+                                       retval = 1;
+                                       *fptr_ptr = (*ce_ptr)->__callstatic;
+                               }
+                       }
+
+                       if (retval == 0) {
+                               if (*ce_ptr) {
+                                       if (error) zend_spprintf(error, 0, "class '%s' does not have a method '%s'", (*ce_ptr)->name, lmname);
+                               } else {
+                                       if (error) zend_spprintf(error, 0, "function '%s' does not exist", lmname);
+                               }
                        }
                }
        } else {