Permalink
Browse files

Fixed bug #47699 (autoload and late static binding)

  • Loading branch information...
1 parent b42f9a7 commit 4a4d739e49eb3e637eb01118696803cde374392c Dmitry Stogov committed Mar 25, 2009
Showing with 28 additions and 1 deletion.
  1. +1 −0 NEWS
  2. +18 −0 Zend/tests/bug47699.phpt
  3. +9 −1 Zend/zend_interfaces.c
View
1 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).
View
18 Zend/tests/bug47699.phpt
@@ -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
View
10 Zend/zend_interfaces.c
@@ -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);
}

0 comments on commit 4a4d739

Please sign in to comment.