Skip to content

Commit

Permalink
Revert "Fixed bug #76980"
Browse files Browse the repository at this point in the history
This reverts commit 35353dc.

This changes causes issues for Symfony, see
symfony/symfony#32395. I'm reverting it
from PHP 7.2 and PHP 7.3 and only leaving it in PHP 7.4.
  • Loading branch information
nikic committed Jul 9, 2019
1 parent 40f7533 commit 22ed362
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 29 deletions.
12 changes: 4 additions & 8 deletions Zend/tests/bug49908.phpt
Expand Up @@ -13,22 +13,18 @@ spl_autoload_register(function ($className) {
}
});

try {
new Foo();
} catch (Exception $e) { }

// We never reach here.
var_dump(new Foo());
new Foo;

?>
--EXPECTF--
string(3) "Foo"
string(3) "Bar"

Fatal error: During class fetch: Uncaught Exception: Bar in %s:%d
Fatal error: Uncaught Exception: Bar in %s:%d
Stack trace:
#0 [internal function]: {closure}('Bar')
#1 %s(%d): spl_autoload_call('Bar')
#2 [internal function]: {closure}('Foo')
#3 %s(%d): spl_autoload_call('Foo')
#4 {main} in %s on line %d
#4 {main}
thrown in %s on line %d
28 changes: 7 additions & 21 deletions Zend/zend_execute_API.c
Expand Up @@ -1424,28 +1424,14 @@ zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *
if (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) {
return zend_lookup_class_ex(class_name, key, 0);
} else if ((ce = zend_lookup_class_ex(class_name, key, 1)) == NULL) {
if (fetch_type & ZEND_FETCH_CLASS_SILENT) {
return NULL;
}
if (EG(exception)) {
if (!(fetch_type & ZEND_FETCH_CLASS_EXCEPTION)) {
zend_string *exception_str;
zval exception_zv;
ZVAL_OBJ(&exception_zv, EG(exception));
Z_ADDREF(exception_zv);
zend_clear_exception();
exception_str = zval_get_string(&exception_zv);
zend_error_noreturn(E_ERROR,
"During class fetch: Uncaught %s", ZSTR_VAL(exception_str));
if ((fetch_type & ZEND_FETCH_CLASS_SILENT) == 0 && !EG(exception)) {
if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
zend_throw_or_error(fetch_type, NULL, "Interface '%s' not found", ZSTR_VAL(class_name));
} else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) {
zend_throw_or_error(fetch_type, NULL, "Trait '%s' not found", ZSTR_VAL(class_name));
} else {
zend_throw_or_error(fetch_type, NULL, "Class '%s' not found", ZSTR_VAL(class_name));
}
return NULL;
}
if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
zend_throw_or_error(fetch_type, NULL, "Interface '%s' not found", ZSTR_VAL(class_name));
} else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) {
zend_throw_or_error(fetch_type, NULL, "Trait '%s' not found", ZSTR_VAL(class_name));
} else {
zend_throw_or_error(fetch_type, NULL, "Class '%s' not found", ZSTR_VAL(class_name));
}
return NULL;
}
Expand Down

0 comments on commit 22ed362

Please sign in to comment.