- Issue created by @ressa
- 🇨🇦Canada teknocat
I noticed this happening as well, but it's not just if you don't make any changes. Even if you do make changes, it saves a nested configuration set, leaving the parent with the previous values, for example:
community_member: community_member: path: /user/register-community-member url: /user/register/community_member redirect_path: /<front> hidden: 0 form_mode_register: register form_mode_edit: default path: /user/register-community-member url: /user/register/community_member redirect_path: /user/login hidden: 0 form_mode_register: register form_mode_edit: default
- 🇨🇦Canada teknocat
The issue is in the submitForm function in the way that it tries to set the given configuration key with the new data merged with ALL the original config data. That array merge is appending the new config that's only for the one $rid to the end of ALL the configuration. Then, it sets that new array in the configuration with that $rid as the configuration key. As a result, every save keeps a nested copy of the original config along with the new config keys. That then throws things off when you try to import the config and use it.
If you want to merge the new config with the original, then instead of $config->getOriginal() you should use $config->get($rid). However, I don't see any need for merging anyway, since you're setting a new array containing ALL the config values that were submitted. Merging the array is only helpful when you want to combine some new data into an existing array, where existing keys that match will be updated while new keys will be added.
Lines 190 to 200 can be changed to the following and it works as expected:
$data = [ 'path' => $alias, 'url' => $source, 'redirect_path' => $redirectPath, 'hidden' => $isHidden, 'form_mode_register' => $formModeRegister, 'form_mode_edit' => $formModeEdit, ]; $config->set($rid, $data) ->save();
- @teknocat opened merge request.