Skip to content

Commit 5063a70

Browse files
committed
Merge branch 'PHP-7.4'
2 parents 6376182 + c666f6e commit 5063a70

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

Zend/tests/bug49908.phpt

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

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

1823
?>
1924
--EXPECTF--
2025
string(3) "Foo"
2126
string(3) "Bar"
2227

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

Zend/zend_execute_API.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,14 +1357,28 @@ zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string
13571357
if (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) {
13581358
return zend_lookup_class_ex(class_name, key, 0);
13591359
} else if ((ce = zend_lookup_class_ex(class_name, key, 1)) == NULL) {
1360-
if ((fetch_type & ZEND_FETCH_CLASS_SILENT) == 0 && !EG(exception)) {
1361-
if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
1362-
zend_throw_or_error(fetch_type, NULL, "Interface '%s' not found", ZSTR_VAL(class_name));
1363-
} else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) {
1364-
zend_throw_or_error(fetch_type, NULL, "Trait '%s' not found", ZSTR_VAL(class_name));
1365-
} else {
1366-
zend_throw_or_error(fetch_type, NULL, "Class '%s' not found", ZSTR_VAL(class_name));
1360+
if (fetch_type & ZEND_FETCH_CLASS_SILENT) {
1361+
return NULL;
1362+
}
1363+
if (EG(exception)) {
1364+
if (!(fetch_type & ZEND_FETCH_CLASS_EXCEPTION)) {
1365+
zend_string *exception_str;
1366+
zval exception_zv;
1367+
ZVAL_OBJ(&exception_zv, EG(exception));
1368+
Z_ADDREF(exception_zv);
1369+
zend_clear_exception();
1370+
exception_str = zval_get_string(&exception_zv);
1371+
zend_error_noreturn(E_ERROR,
1372+
"During class fetch: Uncaught %s", ZSTR_VAL(exception_str));
13671373
}
1374+
return NULL;
1375+
}
1376+
if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
1377+
zend_throw_or_error(fetch_type, NULL, "Interface '%s' not found", ZSTR_VAL(class_name));
1378+
} else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) {
1379+
zend_throw_or_error(fetch_type, NULL, "Trait '%s' not found", ZSTR_VAL(class_name));
1380+
} else {
1381+
zend_throw_or_error(fetch_type, NULL, "Class '%s' not found", ZSTR_VAL(class_name));
13681382
}
13691383
return NULL;
13701384
}

0 commit comments

Comments
 (0)