Skip to content

Commit 2a823f5

Browse files
committed
Don't be lazy, fix it entirely in ext/opcache
1 parent a1a02ec commit 2a823f5

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

Zend/zend_inheritance.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3375,9 +3375,7 @@ ZEND_API zend_class_entry *zend_try_early_bind(zend_class_entry *ce, zend_class_
33753375
}
33763376

33773377
uint32_t is_cacheable = ce->ce_flags & ZEND_ACC_IMMUTABLE;
3378-
if (parent_ce) {
3379-
UPDATE_IS_CACHEABLE(parent_ce);
3380-
}
3378+
UPDATE_IS_CACHEABLE(parent_ce);
33813379
if (is_cacheable) {
33823380
if (zend_inheritance_cache_get && zend_inheritance_cache_add) {
33833381
zend_class_entry *ret = zend_inheritance_cache_get(ce, parent_ce, NULL);
@@ -3394,14 +3392,10 @@ ZEND_API zend_class_entry *zend_try_early_bind(zend_class_entry *ce, zend_class_
33943392
proto = ce;
33953393
}
33963394

3397-
if (parent_ce) {
3398-
orig_linking_class = CG(current_linking_class);
3399-
CG(current_linking_class) = NULL;
3400-
status = zend_can_early_bind(ce, parent_ce);
3401-
CG(current_linking_class) = orig_linking_class;
3402-
} else {
3403-
status = INHERITANCE_SUCCESS;
3404-
}
3395+
orig_linking_class = CG(current_linking_class);
3396+
CG(current_linking_class) = NULL;
3397+
status = zend_can_early_bind(ce, parent_ce);
3398+
CG(current_linking_class) = orig_linking_class;
34053399
if (EXPECTED(status != INHERITANCE_UNRESOLVED)) {
34063400
if (ce->ce_flags & ZEND_ACC_IMMUTABLE) {
34073401
/* Lazy class loading */
@@ -3426,11 +3420,9 @@ ZEND_API zend_class_entry *zend_try_early_bind(zend_class_entry *ce, zend_class_
34263420
zend_begin_record_errors();
34273421
}
34283422

3429-
if (parent_ce) {
3430-
zend_do_inheritance_ex(ce, parent_ce, status == INHERITANCE_SUCCESS);
3431-
if (parent_ce->num_interfaces) {
3432-
zend_do_inherit_interfaces(ce, parent_ce);
3433-
}
3423+
zend_do_inheritance_ex(ce, parent_ce, status == INHERITANCE_SUCCESS);
3424+
if (parent_ce && parent_ce->num_interfaces) {
3425+
zend_do_inherit_interfaces(ce, parent_ce);
34343426
}
34353427
zend_build_properties_info_table(ce);
34363428
if ((ce->ce_flags & (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) == ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) {

ext/opcache/zend_accelerator_util_funcs.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,14 @@ static void zend_accel_do_delayed_early_binding(
360360
zend_class_entry *parent_ce = !(orig_ce->ce_flags & ZEND_ACC_LINKED)
361361
? zend_hash_find_ex_ptr(EG(class_table), early_binding->lc_parent_name, 1)
362362
: NULL;
363-
if (parent_ce || (orig_ce->ce_flags & ZEND_ACC_LINKED)
364-
|| ZSTR_LEN(early_binding->lc_parent_name) == 0) {
363+
if (parent_ce || (orig_ce->ce_flags & ZEND_ACC_LINKED)) {
365364
ce = zend_try_early_bind(orig_ce, parent_ce, early_binding->lcname, zv);
365+
} else if (ZSTR_LEN(early_binding->lc_parent_name) == 0) {
366+
/* Parentless class: use the same binding path as the VM handler */
367+
zval lcname_zv[2];
368+
ZVAL_STR(&lcname_zv[0], early_binding->lcname);
369+
ZVAL_STR(&lcname_zv[1], early_binding->rtd_key);
370+
ce = zend_bind_class_in_slot(zv, lcname_zv, early_binding->lc_parent_name);
366371
}
367372
}
368373
if (ce && early_binding->cache_slot != (uint32_t) -1) {

0 commit comments

Comments
 (0)