Skip to content

Commit 0abcb23

Browse files
committed
Fix handling of linking in progress state during variance checks
1 parent d3be4dd commit 0abcb23

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

Zend/zend_inheritance.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,18 @@ static zend_bool class_visible(zend_class_entry *ce) {
199199
static zend_class_entry *lookup_class(const zend_function *fe, zend_string *name) {
200200
zend_class_entry *ce;
201201
if (!CG(in_compilation)) {
202-
return zend_lookup_class(name);
203-
}
204-
205-
ce = zend_lookup_class_ex(name, NULL, /* autoload */ 0);
206-
if (ce && class_visible(ce)) {
207-
return ce;
202+
ce = zend_lookup_class(name);
203+
if (ce) {
204+
return ce;
205+
}
206+
} else {
207+
ce = zend_lookup_class_ex(name, NULL, /* autoload */ 0);
208+
if (ce && class_visible(ce)) {
209+
return ce;
210+
}
208211
}
209212

210-
/* When checking whether early binding is possible, the current class will not be registered
211-
* yet, so check for it explicitly. */
213+
/* The current class may not be registered yet, so check for it explicitly. */
212214
if (zend_string_equals_ci(fe->common.scope->name, name)) {
213215
return fe->common.scope;
214216
}
@@ -219,7 +221,7 @@ static zend_class_entry *lookup_class(const zend_function *fe, zend_string *name
219221
/* Instanceof that's safe to use on unlinked classes. For the unlinked case, we only handle
220222
* class identity here. */
221223
static zend_bool unlinked_instanceof(zend_class_entry *ce1, zend_class_entry *ce2) {
222-
if ((ce1->ce_flags & ZEND_ACC_LINKED) && (ce2->ce_flags & ZEND_ACC_LINKED)) {
224+
if ((ce1->ce_flags & (ZEND_ACC_LINKED|ZEND_ACC_LINKING_IN_PROGRESS))) {
223225
return instanceof_function(ce1, ce2);
224226
}
225227
return ce1 == ce2;

Zend/zend_operators.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,7 +2260,7 @@ static zend_bool ZEND_FASTCALL instanceof_interface_only(const zend_class_entry
22602260
uint32_t i;
22612261

22622262
if (instance_ce->num_interfaces) {
2263-
ZEND_ASSERT(instance_ce->ce_flags & ZEND_ACC_LINKED);
2263+
ZEND_ASSERT(instance_ce->ce_flags & (ZEND_ACC_LINKED|ZEND_ACC_LINKING_IN_PROGRESS));
22642264
for (i = 0; i < instance_ce->num_interfaces; i++) {
22652265
if (instanceof_interface_only(instance_ce->interfaces[i], ce)) {
22662266
return 1;
@@ -2288,7 +2288,7 @@ static zend_bool ZEND_FASTCALL instanceof_interface(const zend_class_entry *inst
22882288
uint32_t i;
22892289

22902290
if (instance_ce->num_interfaces) {
2291-
ZEND_ASSERT(instance_ce->ce_flags & ZEND_ACC_LINKED);
2291+
ZEND_ASSERT(instance_ce->ce_flags & (ZEND_ACC_LINKED|ZEND_ACC_LINKING_IN_PROGRESS));
22922292
for (i = 0; i < instance_ce->num_interfaces; i++) {
22932293
if (instanceof_interface(instance_ce->interfaces[i], ce)) {
22942294
return 1;

0 commit comments

Comments
 (0)