diff options
| author | Dmitry Stogov <dmitry@php.net> | 2009-03-25 10:39:26 +0000 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@php.net> | 2009-03-25 10:39:26 +0000 |
| commit | 4a4d739e49eb3e637eb01118696803cde374392c (patch) | |
| tree | 8412fc4b3ecb72c701f4e2bab8a7a819b790aa05 | |
| parent | b42f9a7f7d59db44e63334454716dd94711de579 (diff) | |
| download | php-git-4a4d739e49eb3e637eb01118696803cde374392c.tar.gz | |
Fixed bug #47699 (autoload and late static binding)
| -rw-r--r-- | NEWS | 1 | ||||
| -rw-r--r-- | Zend/tests/bug47699.phpt | 18 | ||||
| -rwxr-xr-x | Zend/zend_interfaces.c | 10 |
3 files changed, 28 insertions, 1 deletions
@@ -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-- +<?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 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); } |
