Skip to content

Commit 5e9aca2

Browse files
committed
Fix internal enums
1 parent 96461b6 commit 5e9aca2

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

Zend/zend_API.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type) /
15041504
class_type->ce_flags = ce_flags;
15051505
}
15061506

1507-
if (class_type->ce_flags & ZEND_ACC_ENUM && class_type->enum_backing_type != IS_UNDEF) {
1507+
if (class_type->type == ZEND_USER_CLASS && class_type->ce_flags & ZEND_ACC_ENUM && class_type->enum_backing_type != IS_UNDEF) {
15081508
zend_enum_build_backed_enum_table(class_type);
15091509
}
15101510

Zend/zend_enum.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ void zend_enum_add_interfaces(zend_class_entry *ce)
187187

188188
void zend_enum_build_backed_enum_table(zend_class_entry *ce)
189189
{
190+
ZEND_ASSERT(ce->ce_flags & ZEND_ACC_ENUM);
191+
ZEND_ASSERT(ce->type == ZEND_USER_CLASS);
192+
190193
uint32_t backing_type = ce->enum_backing_type;
191194
ZEND_ASSERT(backing_type != IS_UNDEF);
192195

@@ -266,7 +269,7 @@ static ZEND_NAMED_FUNCTION(zend_enum_cases_func)
266269

267270
ZEND_API zend_result zend_enum_get_case_by_value(zend_object **result, zend_class_entry *ce, zend_long long_key, zend_string *string_key, bool try)
268271
{
269-
if (!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
272+
if (ce->type == ZEND_USER_CLASS && !(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) {
270273
zend_update_class_constants(ce);
271274
}
272275

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5898,7 +5898,7 @@ ZEND_VM_HANDLER(181, ZEND_FETCH_CLASS_CONSTANT, VAR|CONST|UNUSED|CLASS_FETCH, CO
58985898
value = &c->value;
58995899
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
59005900
ce = c->ce;
5901-
if (ce->ce_flags & ZEND_ACC_ENUM && ce->enum_backing_type != IS_UNDEF) {
5901+
if (ce->ce_flags & ZEND_ACC_ENUM && ce->type == ZEND_USER_CLASS && ce->enum_backing_type != IS_UNDEF) {
59025902
// Enums require loading of all class constants to build the backed enum table
59035903
zend_update_class_constants(ce);
59045904
} else {

Zend/zend_vm_execute.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7067,7 +7067,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_CONSTANT_SPEC_CONS
70677067
value = &c->value;
70687068
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
70697069
ce = c->ce;
7070-
if (ce->ce_flags & ZEND_ACC_ENUM && ce->enum_backing_type != IS_UNDEF) {
7070+
if (ce->ce_flags & ZEND_ACC_ENUM && ce->type == ZEND_USER_CLASS && ce->enum_backing_type != IS_UNDEF) {
70717071
// Enums require loading of all class constants to build the backed enum table
70727072
zend_update_class_constants(ce);
70737073
} else {
@@ -24618,7 +24618,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_CONSTANT_SPEC_VAR_
2461824618
value = &c->value;
2461924619
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
2462024620
ce = c->ce;
24621-
if (ce->ce_flags & ZEND_ACC_ENUM && ce->enum_backing_type != IS_UNDEF) {
24621+
if (ce->ce_flags & ZEND_ACC_ENUM && ce->type == ZEND_USER_CLASS && ce->enum_backing_type != IS_UNDEF) {
2462224622
// Enums require loading of all class constants to build the backed enum table
2462324623
zend_update_class_constants(ce);
2462424624
} else {
@@ -33462,7 +33462,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_CONSTANT_SPEC_UNUS
3346233462
value = &c->value;
3346333463
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
3346433464
ce = c->ce;
33465-
if (ce->ce_flags & ZEND_ACC_ENUM && ce->enum_backing_type != IS_UNDEF) {
33465+
if (ce->ce_flags & ZEND_ACC_ENUM && ce->type == ZEND_USER_CLASS && ce->enum_backing_type != IS_UNDEF) {
3346633466
// Enums require loading of all class constants to build the backed enum table
3346733467
zend_update_class_constants(ce);
3346833468
} else {

0 commit comments

Comments
 (0)