@@ -1081,12 +1081,13 @@ static void perform_delayable_implementation_check(
1081
1081
/**
1082
1082
* @param check_only Set to false to throw compile errors on incompatible methods, or true to return INHERITANCE_ERROR.
1083
1083
* @param checked Whether the compatibility check has already succeeded in zend_can_early_bind().
1084
+ * @param force_mutable Whether we know that child may be modified, i.e. doesn't live in shm.
1084
1085
*/
1085
1086
static zend_always_inline inheritance_status do_inheritance_check_on_method_ex (
1086
1087
zend_function * child , zend_class_entry * child_scope ,
1087
1088
zend_function * parent , zend_class_entry * parent_scope ,
1088
1089
zend_class_entry * ce , zval * child_zv ,
1089
- bool check_visibility , bool check_only , bool checked ) /* {{{ */
1090
+ bool check_visibility , bool check_only , bool checked , bool force_mutable ) /* {{{ */
1090
1091
{
1091
1092
uint32_t child_flags ;
1092
1093
uint32_t parent_flags = parent -> common .fn_flags ;
@@ -1188,13 +1189,7 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex(
1188
1189
perform_delayable_implementation_check (ce , child , child_scope , parent , parent_scope );
1189
1190
}
1190
1191
1191
- if (
1192
- !check_only
1193
- && (
1194
- child -> common .scope == ce
1195
- || (child -> common .fn_flags & ZEND_ACC_TRAIT_CLONE )
1196
- )
1197
- ) {
1192
+ if (!check_only && (child -> common .scope == ce || force_mutable )) {
1198
1193
child -> common .fn_flags &= ~ZEND_ACC_OVERRIDE ;
1199
1194
}
1200
1195
@@ -1207,7 +1202,7 @@ static zend_never_inline void do_inheritance_check_on_method(
1207
1202
zend_function * parent , zend_class_entry * parent_scope ,
1208
1203
zend_class_entry * ce , zval * child_zv , bool check_visibility )
1209
1204
{
1210
- do_inheritance_check_on_method_ex (child , child_scope , parent , parent_scope , ce , child_zv , check_visibility , 0 , 0 );
1205
+ do_inheritance_check_on_method_ex (child , child_scope , parent , parent_scope , ce , child_zv , check_visibility , 0 , 0 , /* force_mutable */ false );
1211
1206
}
1212
1207
1213
1208
static zend_always_inline void do_inherit_method (zend_string * key , zend_function * parent , zend_class_entry * ce , bool is_interface , bool checked ) /* {{{ */
@@ -1225,7 +1220,7 @@ static zend_always_inline void do_inherit_method(zend_string *key, zend_function
1225
1220
if (checked ) {
1226
1221
do_inheritance_check_on_method_ex (
1227
1222
func , func -> common .scope , parent , parent -> common .scope , ce , child ,
1228
- /* check_visibility */ 1 , 0 , checked );
1223
+ /* check_visibility */ 1 , 0 , checked , /* force_mutable */ false );
1229
1224
} else {
1230
1225
do_inheritance_check_on_method (
1231
1226
func , func -> common .scope , parent , parent -> common .scope , ce , child ,
@@ -2011,9 +2006,9 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_
2011
2006
if (check_inheritance ) {
2012
2007
/* Inherited members are overridden by members inserted by traits.
2013
2008
* Check whether the trait method fulfills the inheritance requirements. */
2014
- do_inheritance_check_on_method (
2009
+ do_inheritance_check_on_method_ex (
2015
2010
fn , fixup_trait_scope (fn , ce ), existing_fn , fixup_trait_scope (existing_fn , ce ),
2016
- ce , NULL , /* check_visibility */ 1 );
2011
+ ce , NULL , /* check_visibility */ 1 , false, false, /* force_mutable */ true );
2017
2012
}
2018
2013
}
2019
2014
/* }}} */
@@ -3250,7 +3245,7 @@ static inheritance_status zend_can_early_bind(zend_class_entry *ce, zend_class_e
3250
3245
do_inheritance_check_on_method_ex (
3251
3246
child_func , child_func -> common .scope ,
3252
3247
parent_func , parent_func -> common .scope ,
3253
- ce , NULL , /* check_visibility */ 1 , 1 , 0 );
3248
+ ce , NULL , /* check_visibility */ 1 , 1 , 0 , /* force_mutable */ false );
3254
3249
if (UNEXPECTED (status == INHERITANCE_WARNING )) {
3255
3250
overall_status = INHERITANCE_WARNING ;
3256
3251
} else if (UNEXPECTED (status != INHERITANCE_SUCCESS )) {
0 commit comments