From: Dmitry Stogov Date: Wed, 25 Mar 2009 10:39:26 +0000 (+0000) Subject: Fixed bug #47699 (autoload and late static binding) X-Git-Tag: php-5.3.0RC2~288 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a4d739e49eb3e637eb01118696803cde374392c;p=php Fixed bug #47699 (autoload and late static binding) --- diff --git a/NEWS b/NEWS index b3d43eeb07..889b18b721 100644 --- 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 index 0000000000..23ea5a494d --- /dev/null +++ b/Zend/tests/bug47699.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #47699 (autoload and late static binding) +--FILE-- + +--EXPECTF-- +BB +Fatal error: Class 'X' not found in %sbug47699.php on line %d diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index 96ef70f21f..10c4a356e1 100755 --- a/Zend/zend_interfaces.c +++ b/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); }