diff options
author | Nikita Popov <nikic@php.net> | 2016-03-18 20:26:24 +0100 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2016-03-18 20:28:58 +0100 |
commit | 8023204d219d353b83f19edb0133483d67aedcfb (patch) | |
tree | ca448deda1e233f90e90ed00206dc5dcf2432942 /ext/spl/php_spl.c | |
parent | a2522efa9ff409c2cbce7111735e0982e9cad1e6 (diff) | |
download | php-git-8023204d219d353b83f19edb0133483d67aedcfb.tar.gz |
Fixed bug #52339
Autoloader 101: Don't throw if you fail. PHP will throw for you.
Diffstat (limited to 'ext/spl/php_spl.c')
-rw-r--r-- | ext/spl/php_spl.c | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 9c7611d117..87fb2ae37b 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -307,7 +307,7 @@ static int spl_autoload(zend_string *class_name, zend_string *lc_name, const cha Default implementation for __autoload() */ PHP_FUNCTION(spl_autoload) { - int found = 0, pos_len, pos1_len; + int pos_len, pos1_len; char *pos, *pos1; zend_string *class_name, *lc_name, *file_exts = SPL_G(autoload_extensions); @@ -333,32 +333,12 @@ PHP_FUNCTION(spl_autoload) pos1_len = pos_len; } if (spl_autoload(class_name, lc_name, pos, pos1_len)) { - found = 1; break; /* loaded */ } pos = pos1 ? pos1 + 1 : NULL; pos_len = pos1? pos_len - pos1_len - 1 : 0; } zend_string_free(lc_name); - - if (!found && !SPL_G(autoload_running)) { - /* 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. - */ - zend_execute_data *ex = EX(prev_execute_data); - - while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) { - ex = ex->prev_execute_data; - } - if (ex && - ex->opline->opcode != ZEND_FETCH_CLASS && - ex->opline->opcode != ZEND_NEW) { - zend_throw_exception_ex(spl_ce_LogicException, 0, "Class %s could not be loaded", ZSTR_VAL(class_name)); - } else { - php_error_docref(NULL, E_ERROR, "Class %s could not be loaded", ZSTR_VAL(class_name)); - } - } } /* }}} */ /* {{{ proto string spl_autoload_extensions([string file_extensions]) |