helly Sat Jul 12 14:58:07 2008 UTC Added files: /php-src/ext/spl/tests spl_autoload_012.phpt
Modified files: /php-src/ext/spl php_spl.c Log: - Allow multiple exceptions in spl's autoload http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.134&r2=1.135&diff_format=u Index: php-src/ext/spl/php_spl.c diff -u php-src/ext/spl/php_spl.c:1.134 php-src/ext/spl/php_spl.c:1.135 --- php-src/ext/spl/php_spl.c:1.134 Thu Jul 3 12:21:25 2008 +++ php-src/ext/spl/php_spl.c Sat Jul 12 14:58:06 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_spl.c,v 1.134 2008/07/03 12:21:25 felipe Exp $ */ +/* $Id: php_spl.c,v 1.135 2008/07/12 14:58:06 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -371,13 +371,21 @@ ZVAL_ZSTRL(zclass_name, ZEND_STR_TYPE, class_name, class_name_len, 1); if (SPL_G(autoload_functions)) { int l_autoload_running = SPL_G(autoload_running); + zval *exception = NULL; SPL_G(autoload_running) = 1; lc_name = zend_u_str_tolower_dup(ZEND_STR_TYPE, class_name, class_name_len); zend_hash_internal_pointer_reset_ex(SPL_G(autoload_functions), &function_pos); - while(zend_hash_has_more_elements_ex(SPL_G(autoload_functions), &function_pos) == SUCCESS && !EG(exception)) { + while(zend_hash_has_more_elements_ex(SPL_G(autoload_functions), &function_pos) == SUCCESS) { func_name_type = zend_hash_get_current_key_ex(SPL_G(autoload_functions), &func_name, &func_name_len, &dummy, 0, &function_pos); zend_hash_get_current_data_ex(SPL_G(autoload_functions), (void **) &alfi, &function_pos); zend_u_call_method(alfi->obj ? &alfi->obj : NULL, alfi->ce, &alfi->func_ptr, func_name_type, func_name, func_name_len, &retval, 1, zclass_name, NULL TSRMLS_CC); + if (EG(exception)) { + if (exception) { + zend_update_property(zend_exception_get_default(TSRMLS_C), EG(exception), "previous", sizeof("previous")-1, exception TSRMLS_CC); + } + exception = EG(exception); + EG(exception) = NULL; + } if (retval) { zval_ptr_dtor(&retval); } @@ -386,6 +394,7 @@ } zend_hash_move_forward_ex(SPL_G(autoload_functions), &function_pos); } + EG(exception) = exception; efree(lc_name.v); SPL_G(autoload_running) = l_autoload_running; } else { http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/spl_autoload_012.phpt?view=markup&rev=1.1 Index: php-src/ext/spl/tests/spl_autoload_012.phpt +++ php-src/ext/spl/tests/spl_autoload_012.phpt --TEST-- SPL: spl_autoload() capturing multiple Exceptions in __autoload --FILE-- <?php function autoload_first($name) { echo __METHOD__ . "\n"; throw new Exception('first'); } function autoload_second($name) { echo __METHOD__ . "\n"; throw new Exception('second'); } spl_autoload_register('autoload_first'); spl_autoload_register('autoload_second'); class_exists('ThisClassDoesNotExist'); ?> ===DONE=== --EXPECTF-- autoload_first autoload_second Fatal error: Uncaught exception 'Exception' with message 'first' in %sspl_autoload_012.php:%d Stack trace: #0 [internal function]: autoload_first('ThisClassDoesNo...') #1 [internal function]: spl_autoload_call('ThisClassDoesNo...') #2 %sspl_autoload_012.php(%d): class_exists('ThisClassDoesNo...') #3 {main} Next exception 'Exception' with message 'second' in %sspl_autoload_012.php:%d Stack trace: #0 [internal function]: autoload_second('ThisClassDoesNo...') #1 [internal function]: spl_autoload_call('ThisClassDoesNo...') #2 %sspl_autoload_012.php(%d): class_exists('ThisClassDoesNo...') #3 {main} thrown in %sspl_autoload_012.php on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php