]> 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:26 +0000 (10:39 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 25 Mar 2009 10:39:26 +0000 (10:39 +0000)
NEWS
Zend/tests/bug47699.phpt [new file with mode: 0644]
Zend/zend_interfaces.c

diff --git a/NEWS b/NEWS
index b3d43eeb07725b39466a1dcbf95c910f162bafe4..889b18b72183d11655b2cd492df6d1031558932e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 200?, PHP 5.3.0 RC 2
+- Fixed bug #47699 (autoload and late static binding). (Dmitry)
 - Fixed bug #44409 (PDO::FETCH_SERIALIZE calls __construct()).
   (matteo at beccati dot com)
 - Fixed bug #42362 - (HTTP status codes 204 and 304 should not be gzipped).
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 96ef70f21f7125b208fbb33104a36568bbddaba6..10c4a356e15d804c5a999b62e6addce434f18cc7 100755 (executable)
@@ -84,7 +84,15 @@ ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce, zend
                        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);
        }