summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-01-08 04:27:29 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-01-08 04:27:29 +0000
commit13f006ac69b32eb7955bd5c79f1f297e624f762b (patch)
tree9a9a418388d6945dda3e5be5ca4a138849e47271
parentc5fb061cbfd4f97f2475801cbcd8b0f59898327b (diff)
downloadphp-git-13f006ac69b32eb7955bd5c79f1f297e624f762b.tar.gz
Fixed bug #38325 (spl_autoload_register() gaves wrong line for "class
not found").
-rw-r--r--NEWS2
-rwxr-xr-xext/spl/php_spl.c10
-rw-r--r--ext/spl/tests/bug38325.phpt11
3 files changed, 22 insertions, 1 deletions
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--
+<?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