@@ -58,7 +58,7 @@ static zend_result zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stag
5858 /* even if on_modify bails out, we have to continue on with restoring,
5959 since there can be allocated variables that would be freed on MM shutdown
6060 and would lead to memory corruption later ini entry is modified again */
61- result = ini_entry -> on_modify (ini_entry , ini_entry -> orig_value , ini_entry -> mh_arg1 , ini_entry -> mh_arg2 , ini_entry -> mh_arg3 , stage );
61+ result = ini_entry -> on_modify (ini_entry , ini_entry -> orig_value , ini_entry -> mh_arg1 , ini_entry -> mh_arg2 , ini_entry -> mh_arg3 , stage , NULL );
6262 } zend_end_try ();
6363 }
6464 if (stage == ZEND_INI_STAGE_RUNTIME && result == FAILURE ) {
@@ -249,21 +249,20 @@ ZEND_API zend_result zend_register_ini_entries_ex(const zend_ini_entry_def *ini_
249249 return FAILURE ;
250250 }
251251
252- zend_string * prev_value = p -> value ;
253-
252+ bool modified = false;
254253 if (((default_value = zend_get_configuration_directive (p -> name )) != NULL ) &&
255- (!p -> on_modify || p -> on_modify (p , Z_STR_P (default_value ), p -> mh_arg1 , p -> mh_arg2 , p -> mh_arg3 , ZEND_INI_STAGE_STARTUP ) == SUCCESS )) {
254+ (!p -> on_modify || p -> on_modify (p , Z_STR_P (default_value ), p -> mh_arg1 , p -> mh_arg2 , p -> mh_arg3 , ZEND_INI_STAGE_STARTUP , & modified ) == SUCCESS )) {
256255
257256 /* Skip assigning the value if the handler has already done so. */
258- if (p -> value == prev_value ) {
257+ if (! modified ) {
259258 p -> value = zend_new_interned_string (zend_string_copy (Z_STR_P (default_value )));
260259 }
261260 } else {
262261 p -> value = ini_entry -> value ?
263262 zend_string_init_interned (ini_entry -> value , ini_entry -> value_length , 1 ) : NULL ;
264263
265264 if (p -> on_modify ) {
266- p -> on_modify (p , p -> value , p -> mh_arg1 , p -> mh_arg2 , p -> mh_arg3 , ZEND_INI_STAGE_STARTUP );
265+ p -> on_modify (p , p -> value , p -> mh_arg1 , p -> mh_arg2 , p -> mh_arg3 , ZEND_INI_STAGE_STARTUP , NULL );
267266 }
268267 }
269268 ini_entry ++ ;
@@ -398,13 +397,14 @@ ZEND_API zend_result zend_alter_ini_entry_ex(zend_string *name, zend_string *new
398397 zend_string * prev_value = ini_entry -> value ;
399398 duplicate = zend_string_copy (new_value );
400399
400+ bool changed_by_on_modify = false;
401401 if (!ini_entry -> on_modify
402- || ini_entry -> on_modify (ini_entry , duplicate , ini_entry -> mh_arg1 , ini_entry -> mh_arg2 , ini_entry -> mh_arg3 , stage ) == SUCCESS ) {
402+ || ini_entry -> on_modify (ini_entry , duplicate , ini_entry -> mh_arg1 , ini_entry -> mh_arg2 , ini_entry -> mh_arg3 , stage , & changed_by_on_modify ) == SUCCESS ) {
403403 if (modified && ini_entry -> orig_value != prev_value ) { /* we already changed the value, free the changed value */
404404 zend_string_release (prev_value );
405405 }
406406 /* Skip assigning the value if the handler has already done so. */
407- if (ini_entry -> value == prev_value ) {
407+ if (! changed_by_on_modify ) {
408408 ini_entry -> value = duplicate ;
409409 } else {
410410 zend_string_release (duplicate );
0 commit comments