Skip to content

Commit 22ed362

Browse files
committed
Revert "Fixed bug #76980"
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.
1 parent 40f7533 commit 22ed362

File tree

2 files changed

+11
-29
lines changed

2 files changed

+11
-29
lines changed

Zend/tests/bug49908.phpt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,18 @@ spl_autoload_register(function ($className) {
1313
}
1414
});
1515

16-
try {
17-
new Foo();
18-
} catch (Exception $e) { }
19-
20-
// We never reach here.
21-
var_dump(new Foo());
16+
new Foo;
2217

2318
?>
2419
--EXPECTF--
2520
string(3) "Foo"
2621
string(3) "Bar"
2722

28-
Fatal error: During class fetch: Uncaught Exception: Bar in %s:%d
23+
Fatal error: Uncaught Exception: Bar in %s:%d
2924
Stack trace:
3025
#0 [internal function]: {closure}('Bar')
3126
#1 %s(%d): spl_autoload_call('Bar')
3227
#2 [internal function]: {closure}('Foo')
3328
#3 %s(%d): spl_autoload_call('Foo')
34-
#4 {main} in %s on line %d
29+
#4 {main}
30+
thrown in %s on line %d

Zend/zend_execute_API.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,28 +1424,14 @@ zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, const zval *
14241424
if (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) {
14251425
return zend_lookup_class_ex(class_name, key, 0);
14261426
} else if ((ce = zend_lookup_class_ex(class_name, key, 1)) == NULL) {
1427-
if (fetch_type & ZEND_FETCH_CLASS_SILENT) {
1428-
return NULL;
1429-
}
1430-
if (EG(exception)) {
1431-
if (!(fetch_type & ZEND_FETCH_CLASS_EXCEPTION)) {
1432-
zend_string *exception_str;
1433-
zval exception_zv;
1434-
ZVAL_OBJ(&exception_zv, EG(exception));
1435-
Z_ADDREF(exception_zv);
1436-
zend_clear_exception();
1437-
exception_str = zval_get_string(&exception_zv);
1438-
zend_error_noreturn(E_ERROR,
1439-
"During class fetch: Uncaught %s", ZSTR_VAL(exception_str));
1427+
if ((fetch_type & ZEND_FETCH_CLASS_SILENT) == 0 && !EG(exception)) {
1428+
if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
1429+
zend_throw_or_error(fetch_type, NULL, "Interface '%s' not found", ZSTR_VAL(class_name));
1430+
} else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) {
1431+
zend_throw_or_error(fetch_type, NULL, "Trait '%s' not found", ZSTR_VAL(class_name));
1432+
} else {
1433+
zend_throw_or_error(fetch_type, NULL, "Class '%s' not found", ZSTR_VAL(class_name));
14401434
}
1441-
return NULL;
1442-
}
1443-
if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
1444-
zend_throw_or_error(fetch_type, NULL, "Interface '%s' not found", ZSTR_VAL(class_name));
1445-
} else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) {
1446-
zend_throw_or_error(fetch_type, NULL, "Trait '%s' not found", ZSTR_VAL(class_name));
1447-
} else {
1448-
zend_throw_or_error(fetch_type, NULL, "Class '%s' not found", ZSTR_VAL(class_name));
14491435
}
14501436
return NULL;
14511437
}

0 commit comments

Comments
 (0)