]> granicus.if.org Git - php/commitdiff
Fix #45656 (new Class silenting exceptions in autoloaders)
authorEtienne Kneuss <colder@php.net>
Mon, 15 Sep 2008 10:19:15 +0000 (10:19 +0000)
committerEtienne Kneuss <colder@php.net>
Mon, 15 Sep 2008 10:19:15 +0000 (10:19 +0000)
Zend/zend_execute_API.c
ext/spl/tests/spl_autoload_012.phpt

index f22fae6aa24e726dfb0440c925e7e316925c4ada..8af6bf71f02162a9b1f1620a7ec9eb219eef575b 100644 (file)
@@ -1032,7 +1032,6 @@ ZEND_API int zend_u_lookup_class_ex(zend_uchar type, zstr name, int name_length,
        int retval;
        unsigned int lc_name_len;
        zstr lc_name, lc_free;
-       zval *exception;
        char dummy = 1;
        zend_fcall_info fcall_info;
        zend_fcall_info_cache fcall_cache;
@@ -1116,9 +1115,10 @@ ZEND_API int zend_u_lookup_class_ex(zend_uchar type, zstr name, int name_length,
        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;
 
        if (UG(unicode)) {
@@ -1129,26 +1129,16 @@ ZEND_API int zend_u_lookup_class_ex(zend_uchar type, zstr name, int name_length,
 
        zend_u_hash_del(EG(in_autoload), type, lc_name, lc_name_len + 1);
 
-       if (retval == FAILURE) {
-               zend_exception_restore(TSRMLS_C);
-               if (do_normalize) {
-                       efree(lc_free.v);
-               }
-               return FAILURE;
+       if (retval_ptr) {
+               zval_ptr_dtor(&retval_ptr);
        }
 
-       if (EG(exception) && exception) {
-               zend_exception_restore(TSRMLS_C);
+       if (retval == FAILURE) {
                if (do_normalize) {
                        efree(lc_free.v);
                }
-               zend_error(E_ERROR, "Function %s(%R) threw an exception of type '%v'", ZEND_AUTOLOAD_FUNC_NAME, type, name, Z_OBJCE_P(EG(exception))->name);
                return FAILURE;
        }
-       zend_exception_restore(TSRMLS_C);
-       if (retval_ptr) {
-               zval_ptr_dtor(&retval_ptr);
-       }
 
        retval = zend_u_hash_find(EG(class_table), type, lc_name, lc_name_len + 1, (void **) ce);
        if (do_normalize) {
@@ -1639,15 +1629,13 @@ check_fetch_type:
                        }
                }
                if (use_autoload) {
-                       if (rt_ns_check &&
-                               zend_u_lookup_class_ex(type, lcname, class_name_len, class_name, 0, &pce TSRMLS_CC) == SUCCESS
-                       ) {
+                       if (rt_ns_check && zend_u_lookup_class_ex(type, lcname, class_name_len, class_name, 0, &pce TSRMLS_CC) == SUCCESS) {
                                if (lcname.v != class_name.v) {
                                        efree(lcname.v);
                                }
                                return *pce;
                        }
-                       if (!silent) {
+                       if (!silent && !EG(exception)) {
                                if (fetch_type == ZEND_FETCH_CLASS_INTERFACE) {
                                        zend_error(E_ERROR, "Interface '%R' not found", type, class_name);
                                } else {
index 07e9dfeb6356cd9af977c74b7a5bf6247858df69..e07f0e4fe57a9286a71ef25f3c4ab7e38d40123e 100755 (executable)
@@ -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: