From 145b60e7f8c4af211e953eda3bf8bfea614dfae9 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 25 Mar 2009 10:39:36 +0000 Subject: [PATCH] Fixed bug #47699 (autoload and late static binding) --- Zend/tests/bug47699.phpt | 18 ++++++++++++++++++ Zend/zend_interfaces.c | 10 +++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/bug47699.phpt 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 fcdec9f69a..6ca0c64de6 100755 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -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); } -- 2.50.1