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

Command icon 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:

Comments

viniciusrp created an issue. See original summary.

viniciusrp’s picture

Status: Active » Needs review

I replace "+" used to union an array for array_merge.

viniciusrp’s picture

I created a patch to be applied until next release.

kingdutch’s picture

Title: Applied configuration don't registered » Applied configuration is not stored properly due to incorrect array operator
Status: Needs review » Fixed

kingdutch’s picture

Adding credit for an internal review that pointed out a spot was missed (which was fixed in the eventual commit).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.