Problem/Motivation
I created a config-modify file in a custom module and it should be executed after they installation. When the module is enabled the configuration is being applied, but the filename isn't be registered as applied and when executed again, the configuration is duplicated.
The error happen at: html/modules/contrib/config_modify/src/ConfigInstaller.php:142
$alterations_applied->set("files", $alterations_applied->get("files") + $config_to_alter)->save();
Looking this documentation: https://www.amitmerchant.com/two-ways-to-merge-arrays-in-php/, should be better use array_merge for this code, because using "+" the union is assossiative and can hide some items when both array has the same key.
Steps to reproduce
- Create config-modify file in a module
- Execute config-modify and check the applied-configuration
- As the configuration isn't be saved at applied-configuration, it will be executed again and duplicated the configuration
Proposed resolution
Replace "+" as union and use array_merge function.
Remaining tasks
N/A
User interface changes
N/A
API changes
N/A
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3475008-4-applied-configuration-do-not-registered.patch | 943 bytes | viniciusrp |
Issue fork config_modify-3475008
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3475008-applied-configuration-dont
changes, plain diff MR !4
Comments
Comment #3
viniciusrp commentedI replace "+" used to union an array for array_merge.
Comment #4
viniciusrp commentedI created a patch to be applied until next release.
Comment #6
kingdutchComment #9
kingdutchAdding credit for an internal review that pointed out a spot was missed (which was fixed in the eventual commit).