@@ -4052,7 +4052,8 @@ static void preload_register_trait_methods(zend_class_entry *ce) {
4052
4052
zend_op_array * op_array ;
4053
4053
ZEND_HASH_FOREACH_PTR (& ce -> function_table , op_array ) {
4054
4054
if (!(op_array -> fn_flags & ZEND_ACC_TRAIT_CLONE )) {
4055
- zend_shared_alloc_register_xlat_entry (op_array -> opcodes , op_array );
4055
+ ZEND_ASSERT (op_array -> refcount && "Must have refcount pointer" );
4056
+ zend_shared_alloc_register_xlat_entry (op_array -> refcount , op_array );
4056
4057
}
4057
4058
} ZEND_HASH_FOREACH_END ();
4058
4059
}
@@ -4063,18 +4064,18 @@ static void preload_fix_trait_methods(zend_class_entry *ce)
4063
4064
4064
4065
ZEND_HASH_FOREACH_PTR (& ce -> function_table , op_array ) {
4065
4066
if (op_array -> fn_flags & ZEND_ACC_TRAIT_CLONE ) {
4066
- zend_op_array * orig_op_array = zend_shared_alloc_get_xlat_entry (op_array -> opcodes );
4067
- if (orig_op_array ) {
4068
- zend_class_entry * scope = op_array -> scope ;
4069
- uint32_t fn_flags = op_array -> fn_flags ;
4070
- zend_function * prototype = op_array -> prototype ;
4071
- HashTable * ht = op_array -> static_variables ;
4072
- * op_array = * orig_op_array ;
4073
- op_array -> scope = scope ;
4074
- op_array -> fn_flags = fn_flags ;
4075
- op_array -> prototype = prototype ;
4076
- op_array -> static_variables = ht ;
4077
- }
4067
+ zend_op_array * orig_op_array = zend_shared_alloc_get_xlat_entry (op_array -> refcount );
4068
+ ZEND_ASSERT (orig_op_array && "Must be in xlat table" );
4069
+
4070
+ zend_class_entry * scope = op_array -> scope ;
4071
+ uint32_t fn_flags = op_array -> fn_flags ;
4072
+ zend_function * prototype = op_array -> prototype ;
4073
+ HashTable * ht = op_array -> static_variables ;
4074
+ * op_array = * orig_op_array ;
4075
+ op_array -> scope = scope ;
4076
+ op_array -> fn_flags = fn_flags ;
4077
+ op_array -> prototype = prototype ;
4078
+ op_array -> static_variables = ht ;
4078
4079
}
4079
4080
} ZEND_HASH_FOREACH_END ();
4080
4081
}
@@ -4105,16 +4106,12 @@ static int preload_optimize(zend_persistent_script *script)
4105
4106
}
4106
4107
4107
4108
ZEND_HASH_FOREACH_PTR (& script -> script .class_table , ce ) {
4108
- if (ce -> ce_flags & ZEND_ACC_IMPLEMENT_TRAITS ) {
4109
- preload_fix_trait_methods (ce );
4110
- }
4109
+ preload_fix_trait_methods (ce );
4111
4110
} ZEND_HASH_FOREACH_END ();
4112
4111
4113
4112
ZEND_HASH_FOREACH_PTR (preload_scripts , script ) {
4114
4113
ZEND_HASH_FOREACH_PTR (& script -> script .class_table , ce ) {
4115
- if (ce -> ce_flags & ZEND_ACC_IMPLEMENT_TRAITS ) {
4116
- preload_fix_trait_methods (ce );
4117
- }
4114
+ preload_fix_trait_methods (ce );
4118
4115
} ZEND_HASH_FOREACH_END ();
4119
4116
} ZEND_HASH_FOREACH_END ();
4120
4117
0 commit comments