diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2007-01-08 04:27:29 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2007-01-08 04:27:29 +0000 |
commit | 13f006ac69b32eb7955bd5c79f1f297e624f762b (patch) | |
tree | 9a9a418388d6945dda3e5be5ca4a138849e47271 | |
parent | c5fb061cbfd4f97f2475801cbcd8b0f59898327b (diff) | |
download | php-git-13f006ac69b32eb7955bd5c79f1f297e624f762b.tar.gz |
Fixed bug #38325 (spl_autoload_register() gaves wrong line for "class
not found").
-rw-r--r-- | NEWS | 2 | ||||
-rwxr-xr-x | ext/spl/php_spl.c | 10 | ||||
-rw-r--r-- | ext/spl/tests/bug38325.phpt | 11 |
3 files changed, 22 insertions, 1 deletions
@@ -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-- +<?php if (!extension_loaded("spl")) print "skip"; ?> +--FILE-- +<?php +spl_autoload_register(); +new Foo(); +?> +--EXPECTF-- +Fatal error: spl_autoload(): Class Foo could not be loaded in %s on line 3 |