Config export exports changes in splitted config without confirmation pretending the configuration is identical.

Created on 1 September 2022, almost 3 years ago
Updated 16 March 2023, over 2 years ago

Problem/Motivation

Changes in splitted configuration are exported silently when doing drush cex.
drush cex says :

[notice] The active configuration is identical to the configuration in the export directory (../config/sync).

but exports changes anyway.

It only occurs when changes belong to a splitted configs.

Experienced it with config_split rc1 and rc3 (tested on a core 9.3.21)
Version used :

  • drupal/config_filter 2.4.0
  • drupal/config_ignore 2.3.0
  • drupal/config_split 2.0.0-rc3

Steps to reproduce

Install configs split 2.x

  • Create and activate a split
  • Partial split system.site
  • Export config
  • Change the site name
  • Export config

You'll see

❯ drush cex  
 [notice] The active configuration is identical to the configuration in the export directory (../config/sync).
../config/sync

>>> NO CONFIRMATION

❯ git status
On branch develop
Your branch is up to date with 'origin/develop'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   ../config/dev/system.site.yml

>>> YOU SHOULD NORMALLY HAVE NO CHANGE TO COMMIT

🐛 Bug report
Status

Closed: works as designed

Version

2.0

Component

Code

Created by

🇫🇷France ericdsd France

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇷France ericdsd France

    Hi i missed your comment, i'll test your suggestion then Thanks.

  • 🇫🇷France ericdsd France

    Thanks, switching from directory to collection works like a charm.
    This should probably be explained in module documentation.

  • 🇨🇭Switzerland bircher 🇨🇿

    You are right!
    Feel welcome to update the documentation directly! Missing documentation is one of the last things holding up the 2.0.0 release.
    See 📌 Update documentation for Config Split 2.x Active

  • @bircher There seems to be one major drawback to using Collections, and that is that "when you switch to a different environment and export, it deletes the previously exported collections that aren't active.".

    This makes it impossible to maintain all splits for all environments in source control (GIT), which seems to make the idea of being able to enable different splits for different environments redundant.

    One export on a developer's local machine which has local developer split settings enabled will completely delete and remove from source control, the splits for TEST, STAGING and PRODUCTION environments.

    Am I missing something here?

    We also would like to be given some feedback / CLI output during a drush config-export to show the developer that changes to split files will be made, but changing from 'Folder' method to 'Collection' method does not seem to be the solution if it has this described limitation.

  • 🇨🇭Switzerland bircher 🇨🇿

    @martybfly I think the problem is how you "switch to a different environment"

    The reason it works with folders the way you do it is because the non active folders are not touched at all, but that could also lead to configuration you had being lost or exported to the main sync directory when it should have gone to the folder.

    In Config Split 2 I introduced the difference between activating and enabling and deactivating and disabling.
    Switching environments should be done by deactivating one and activating the other, and not just enabling and disabling splits.
    It gets further complicated because you could do that in the following way in Config Split 1 (which still works in Config Split 2 as well)

    1. export config
    2. change what splits are active (in settings.php for 1.x and 2.x , or via state override in 2.)
    3. import config

    how collections work is that the config of the active split is the active config and when exported it goes into a collection, when imported it goes in the active one. For inactive splits the collection gets imported, and when you export it gets exported untouched.
    Your problem is that you do not deactivate the previous environment, and so it never goes from the active config to the collection inside the active config store and so when you export the config the collection gets removed.

    TLDR: deactivate the environment you are switching from (do not use settings.php to determine which environment is active but use state override)

Production build 0.71.5 2024