From: Arnaud Le Blanc Date: Sat, 25 Apr 2009 21:05:00 +0000 (+0000) Subject: MFB5.3 (Fixed bug #38325 (spl_autoload_register() gaves wrong line for X-Git-Tag: php-5.4.0alpha1~191^2~3841 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=793c221a7d343eb550b868c74f2068e4d5490dc9;p=php MFB5.3 (Fixed bug #38325 (spl_autoload_register() gaves wrong line for "class not found")) --- diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 480eb1009f..181a6ee466 100755 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -311,7 +311,22 @@ PHP_FUNCTION(spl_autoload) EG(active_op_array) = original_active_op_array; if (!found && !SPL_G(autoload_running)) { - zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Class %v 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. + */ + + char *sclass_name; + int sclass_name_len; + + zend_unicode_to_string(ZEND_U_CONVERTER(UG(output_encoding_conv)), &sclass_name, &sclass_name_len, + class_name.u, class_name_len); + + if (active_opline->opcode != ZEND_FETCH_CLASS) { + zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Class %s could not be loaded", sclass_name); + } else { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Class %s could not be loaded", sclass_name); + } } } /* }}} */