]> granicus.if.org Git - php/commitdiff
Fixed bug #47699 (autoload and late static binding)
authorDmitry Stogov <dmitry@php.net>
Wed, 25 Mar 2009 10:39:36 +0000 (10:39 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 25 Mar 2009 10:39:36 +0000 (10:39 +0000)
Zend/tests/bug47699.phpt [new file with mode: 0644]
Zend/zend_interfaces.c

diff --git a/Zend/tests/bug47699.phpt b/Zend/tests/bug47699.phpt
new file mode 100644 (file)
index 0000000..23ea5a4
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Bug #47699 (autoload and late static binding)
+--FILE--
+<?php
+class A {
+       static function test($v='') {
+               print_r(get_called_class());
+       }
+}
+class B extends A {
+}
+B::test();
+spl_autoload_register('B::test');
+new X();
+?>
+--EXPECTF--
+BB
+Fatal error: Class 'X' not found in %sbug47699.php on line %d
index fcdec9f69a2cc36250f902a81af040da6205535d..6ca0c64de69905f4c230c07254311466c5b8063b 100755 (executable)
@@ -85,7 +85,15 @@ ZEND_API zval* zend_u_call_method(zval **object_pp, zend_class_entry *obj_ce, ze
                        fcic.function_handler = *fn_proxy;
                }
                fcic.calling_scope = obj_ce;
-               fcic.called_scope = object_pp ? obj_ce : EG(called_scope);
+               if (object_pp) {
+                       fcic.called_scope = Z_OBJCE_PP(object_pp);
+               } else if (obj_ce &&
+                          !(EG(called_scope) &&
+                            instanceof_function(EG(called_scope), obj_ce TSRMLS_CC))) {
+                       fcic.called_scope = obj_ce;
+               } else {
+                       fcic.called_scope = EG(called_scope);
+               }
                fcic.object_ptr = object_pp ? *object_pp : NULL;
                result = zend_call_function(&fci, &fcic TSRMLS_CC);
        }