Skip to content

Commit 3a9d90f

Browse files
committed
Fexed resolution of method clones
1 parent aea85c6 commit 3a9d90f

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

ext/opcache/Optimizer/zend_optimizer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,10 +1561,12 @@ int zend_optimize_script(zend_script *script, zend_long optimization_level, zend
15611561

15621562
ZEND_ASSERT(orig_op_array != NULL);
15631563
if (orig_op_array != op_array) {
1564+
uint32_t fn_flags = op_array->fn_flags;
15641565
zend_function *prototype = op_array->prototype;
15651566
HashTable *ht = op_array->static_variables;
15661567

15671568
*op_array = *orig_op_array;
1569+
op_array->fn_flags = fn_flags;
15681570
op_array->prototype = prototype;
15691571
op_array->static_variables = ht;
15701572
}

ext/opcache/ZendAccelerator.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3558,13 +3558,17 @@ static int preload_optimize(zend_persistent_script *script)
35583558
ZEND_HASH_FOREACH_PTR(&ce->function_table, op_array) {
35593559
if (op_array->fn_flags & ZEND_ACC_TRAIT_CLONE) {
35603560
zend_op_array *orig_op_array = zend_shared_alloc_get_xlat_entry(op_array->opcodes);
3561-
uint32_t fn_flags = op_array->fn_flags;
3562-
zend_function *prototype = op_array->prototype;
3563-
HashTable *ht = op_array->static_variables;
3564-
*op_array = *orig_op_array;
3565-
op_array->fn_flags = fn_flags;
3566-
op_array->prototype = prototype;
3567-
op_array->static_variables = ht;
3561+
if (orig_op_array) {
3562+
zend_class_entry *scope = op_array->scope;
3563+
uint32_t fn_flags = op_array->fn_flags;
3564+
zend_function *prototype = op_array->prototype;
3565+
HashTable *ht = op_array->static_variables;
3566+
*op_array = *orig_op_array;
3567+
op_array->scope = scope;
3568+
op_array->fn_flags = fn_flags;
3569+
op_array->prototype = prototype;
3570+
op_array->static_variables = ht;
3571+
}
35683572
}
35693573
} ZEND_HASH_FOREACH_END();
35703574
}

0 commit comments

Comments
 (0)