From: Marcus Boerger Date: Tue, 31 Oct 2006 23:18:00 +0000 (+0000) Subject: - Fixed Bug #39313 spl_autoload triggers Fatal error X-Git-Tag: RELEASE_1_0_0RC1~1165 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6a73cbe914bb3f952148c1aa21c602739cf02a24;p=php - Fixed Bug #39313 spl_autoload triggers Fatal error --- diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 18046a436b..b0d10eafb3 100755 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -57,6 +57,7 @@ static PHP_GINIT_FUNCTION(spl) { spl_globals->autoload_extensions = NULL; spl_globals->autoload_functions = NULL; + spl_globals->autoload_running = 0; } /* }}} */ @@ -303,7 +304,7 @@ PHP_FUNCTION(spl_autoload) EG(active_op_array) = original_active_op_array; EG(function_state_ptr) = original_function_state_ptr; - if (!found) { + if (!found && !SPL_G(autoload_running)) { zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "Class %s could not be loaded", class_name); } } /* }}} */ @@ -360,6 +361,8 @@ PHP_FUNCTION(spl_autoload_call) } if (SPL_G(autoload_functions)) { + int l_autoload_running = SPL_G(autoload_running); + SPL_G(autoload_running) = 1; class_name_type = Z_TYPE_P(class_name); class_name_len = Z_UNILEN_P(class_name); lc_name = zend_u_str_tolower_dup(class_name_type, Z_UNIVAL_P(class_name), class_name_len); @@ -378,6 +381,7 @@ PHP_FUNCTION(spl_autoload_call) zend_hash_move_forward_ex(SPL_G(autoload_functions), &function_pos); } efree(lc_name.v); + SPL_G(autoload_running) = l_autoload_running; } else { /* do not use or overwrite &EG(autoload_func) here */ zend_call_method_with_1_params(NULL, NULL, NULL, "spl_autoload", NULL, class_name); diff --git a/ext/spl/php_spl.h b/ext/spl/php_spl.h index 4e8c9b3f7d..fd8e5cb8b9 100755 --- a/ext/spl/php_spl.h +++ b/ext/spl/php_spl.h @@ -58,6 +58,7 @@ PHP_MINFO_FUNCTION(spl); ZEND_BEGIN_MODULE_GLOBALS(spl) char * autoload_extensions; HashTable * autoload_functions; + int autoload_running; ZEND_END_MODULE_GLOBALS(spl) #ifdef ZTS diff --git a/ext/spl/tests/spl_autoload_009.phpt b/ext/spl/tests/spl_autoload_009.phpt new file mode 100755 index 0000000000..c282bf4452 --- /dev/null +++ b/ext/spl/tests/spl_autoload_009.phpt @@ -0,0 +1,28 @@ +--TEST-- +SPL: spl_autoload() and friends +--SKIPIF-- + +--INI-- +include_path=. +--FILE-- + +===DONE=== + +--EXPECTF-- +%stestclass.inc +%stestclass.class.inc +bool(true) +===DONE===