From: Ilia Alshanetsky Date: Mon, 8 Jan 2007 04:27:29 +0000 (+0000) Subject: Fixed bug #38325 (spl_autoload_register() gaves wrong line for "class X-Git-Tag: php-5.2.1RC3~80 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13f006ac69b32eb7955bd5c79f1f297e624f762b;p=php Fixed bug #38325 (spl_autoload_register() gaves wrong line for "class not found"). --- diff --git a/NEWS b/NEWS index 15ff376eba..04397ae7bb 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ PHP NEWS - Fixed bug #39504 (xmlwriter_write_dtd_entity() creates Attlist tag, not entity). (Hannes) - Fixed bug #39394 (Missing check for older variants of openssl). (Ilia) +- Fixed bug #38325 (spl_autoload_register() gaves wrong line for "class + not found"). (Ilia) 04 Jan 2007, PHP 5.2.1RC2 - Small optimization of the date() function (Matt,Ilia) diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 7029139c67..b8e1cfbe19 100755 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -297,7 +297,15 @@ PHP_FUNCTION(spl_autoload) EG(function_state_ptr) = original_function_state_ptr; if (!found && !SPL_G(autoload_running)) { - zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Class %s could not be loaded", class_name); + /* For internal errors, we generate E_ERROR, for direct calls an exception is thrown. + * The "scope" is determined by an opcode, if it is ZEND_FETCH_CLASS we know function was called indirectly by + * the Zend engine. + */ + if (active_opline->opcode != ZEND_FETCH_CLASS) { + zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Class %s could not be loaded", class_name); + } else { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s could not be loaded", class_name); + } } } /* }}} */ diff --git a/ext/spl/tests/bug38325.phpt b/ext/spl/tests/bug38325.phpt new file mode 100644 index 0000000000..126e1f3c02 --- /dev/null +++ b/ext/spl/tests/bug38325.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #38325 (spl_autoload_register() gaves wrong line for "class not found") +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Fatal error: spl_autoload(): Class Foo could not be loaded in %s on line 3