summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtienne Kneuss <colder@php.net>2008-09-15 10:19:53 +0000
committerEtienne Kneuss <colder@php.net>2008-09-15 10:19:53 +0000
commit6ebc3a8b9b38ef391cb1960892edb4be6f54d373 (patch)
tree458f4c31eb7d27820369a8cfa2bd07bd96301f26
parent7251de9eb807f80c927e477b7145971d5d52cfb0 (diff)
downloadphp-git-6ebc3a8b9b38ef391cb1960892edb4be6f54d373.tar.gz
MFH: Fix #45656 (new Class silenting exceptions in autoloaders)
-rw-r--r--Zend/zend_execute_API.c20
-rwxr-xr-xext/spl/tests/spl_autoload_012.phpt12
2 files changed, 18 insertions, 14 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 96aa0bad23..d686740982 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -970,7 +970,6 @@ ZEND_API int zend_lookup_class_ex(const char *name, int name_length, int use_aut
int retval;
char *lc_name;
char *lc_free;
- zval *exception;
zend_fcall_info fcall_info;
zend_fcall_info_cache fcall_cache;
char dummy = 1;
@@ -1035,31 +1034,24 @@ ZEND_API int zend_lookup_class_ex(const char *name, int name_length, int use_aut
fcall_cache.called_scope = NULL;
fcall_cache.object_pp = NULL;
- exception = EG(exception);
zend_exception_save(TSRMLS_C);
retval = zend_call_function(&fcall_info, &fcall_cache TSRMLS_CC);
+ zend_exception_restore(TSRMLS_C);
+
EG(autoload_func) = fcall_cache.function_handler;
zval_ptr_dtor(&class_name_ptr);
zend_hash_del(EG(in_autoload), lc_name, name_length + 1);
- if (retval == FAILURE) {
- zend_exception_restore(TSRMLS_C);
- free_alloca(lc_free, use_heap);
- return FAILURE;
+ if (retval_ptr) {
+ zval_ptr_dtor(&retval_ptr);
}
- if (EG(exception) && exception) {
- zend_exception_restore(TSRMLS_C);
+ if (retval == FAILURE) {
free_alloca(lc_free, use_heap);
- zend_error(E_ERROR, "Function %s(%s) threw an exception of type '%s'", ZEND_AUTOLOAD_FUNC_NAME, name, Z_OBJCE_P(EG(exception))->name);
return FAILURE;
}
- zend_exception_restore(TSRMLS_C);
- if (retval_ptr) {
- zval_ptr_dtor(&retval_ptr);
- }
retval = zend_hash_find(EG(class_table), lc_name, name_length + 1, (void **) ce);
free_alloca(lc_free, use_heap);
@@ -1493,7 +1485,7 @@ check_fetch_type:
if (rt_ns_check && zend_lookup_class_ex(class_name, class_name_len, 1, &pce TSRMLS_CC) == SUCCESS) {
return *pce;
}
- if (!silent) {
+ if (!silent && !EG(exception)) {
if (fetch_type == ZEND_FETCH_CLASS_INTERFACE) {
zend_error(E_ERROR, "Interface '%s' not found", class_name);
} else {
diff --git a/ext/spl/tests/spl_autoload_012.phpt b/ext/spl/tests/spl_autoload_012.phpt
index 07e9dfeb63..e07f0e4fe5 100755
--- a/ext/spl/tests/spl_autoload_012.phpt
+++ b/ext/spl/tests/spl_autoload_012.phpt
@@ -26,6 +26,14 @@ try {
} while($e = $e->getPrevious());
}
+try {
+ new ThisClassDoesNotExist;
+} catch(Exception $e) {
+ do {
+ echo $e->getMessage()."\n";
+ } while($e = $e->getPrevious());
+}
+
class_exists('ThisClassDoesNotExist');
?>
===DONE===
@@ -36,6 +44,10 @@ second
first
autoload_first
autoload_second
+second
+first
+autoload_first
+autoload_second
Fatal error: Uncaught exception 'Exception' with message 'first' in %sspl_autoload_012.php:%d
Stack trace: