Active splits should be considered and imported during site-install

Created on 4 March 2024, 9 months ago

Problem/Motivation

When there is an active split in the exported config, installing a site from scratch via drush si --existing-config requires an additional drush cim. This makes it really hard to recognize if a drush cex step was forgotten as part of a module upgrade on a real-life project.

Steps to reproduce

  1. composer require drush/drush drupal/admin_toolbar drupal/config_split (means drupal/core:10.2.3, drush/drush:12.4.3 and drupal/config_split:2.0.0)
  2. drush si minimal (standard profile cannot be installed from config, sorry)
  3. set $settings['config_sync_directory'] = '../config/sync'; in settings.php
  4. drush en config_split admin_toolbar_tools views_ui
  5. drush cex
  6. under Structure > Views > Settings, enable "Always show the default display" and "Always show advanced display settings" and "Show the SQL query"
  7. create a DEV split:
    • as a folder (../config/dev)
    • status: active, status override: none
    • complete split "Admin Toolbar" and "Admin Toolbar Extra Tools" modules
    • partial split "views.settings" configuration item
  8. drush cex
  9. drush si --existing-config -y; drush upwd admin admin; drush cr; drush cim

Expected behavior: this last drush cim step should report no config overrides.

Actual behavior: this last drush cim step reports config overrides (admin_toolbar.settings and admin_toolbar_tools.settings to create, core.extension and views.settings to update).

We have also tried other versions (every time with the above steps from scratch, so no upgrades at all):

  • drupal/core:10.1.8 with drupal/config_split:1.9.0 AND drupal/config_ignore:2.4.0 – PASS (as the original starting point of the investigation);
  • drupal/core:10.1.8 with drupal/config_split:1.9.0 AND drupal/config_ignore:3.2.0 – FAIL (actually, this is how the problem was spotted first), which is really weird, because:
  • drupal/core:10.1.8 with drupal/config_split:2.0.0, but without drupal/config_ignore at all – FAIL, so it's not about a change in drupal/config_ignore:3.x.x;
  • drupal/core:10.2.3 with drupal/config_split:2.0.0 – FAIL, so and is not a change in drupal/core:10.2.x either;
  • drupal/core:10.2.3 with drupal/config_split:1.9.0 – PASS, so it's definitely a change in drupal/config_split:2.x.x.

Proposed resolution

Active splits should be considered and imported during site-install, so it becomes easier to recognize if a drush cex step was forgotten as part of a module upgrade on a real-life project.

Remaining tasks

Discuss, patch, review, commit, release.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇭🇺Hungary boobaa

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

Comments & Activities

  • Issue created by @boobaa
  • 🇭🇺Hungary mxr576 Hungary

    After some investigation I think the major difference between 2.x and 1.x that 2.x is now uses an event subscriber for importing splitted configurations (https://git.drupalcode.org/project/config_split/-/blob/2.0.0/src/EventSu...) but 1.x used to do the same via integrating with Config Filter (https://git.drupalcode.org/project/config_split/-/blob/8.x-1.9/src/Plugi...) and Config Filter 1.x used to override the config storage in service container compilation time (https://git.drupalcode.org/project/config_filter/-/blob/8.x-1.x/src/Conf...) but it also uses an event subscriber in Config Filter 2.x (https://git.drupalcode.org/project/config_filter/-/blob/8.x-2.x/src/Conf...).

    The Config Split 2.x even subscriber also has a could be relevant comment:

        // Unfortunately we can not load the existing splits from the drupal because
        // the subscribed events is compiled into the container in a compiler pass
        // and at that point we can not access the container yet of course.
    

    So probably what should be double checked is which version of Config Filter was installed in these configurations:

    drupal/core:10.1.8 with drupal/config_split:1.9.0 AND drupal/config_ignore:2.4.0 – PASS (as the original starting point of the investigation);
    drupal/core:10.1.8 with drupal/config_split:1.9.0 AND drupal/config_ignore:3.2.0 – FAIL (actually, this is how the problem was spotted first), which is really weird, because:

    So maybe... maybe... leveraging events for this will turn out to be an insufficient solution.

  • 🇭🇺Hungary boobaa

    In cases of drupal/core:10.1.8 with drupal/config_split:1.9.0, drupal/config_filter:1.12.0 was used, because that's the latest version of it anyway, and drupal/config_split:1.9.0 depends on drupal/config_filter:^1.

  • 🇭🇺Hungary mxr576 Hungary

    Added the issue where config ignore switched to the new approach.

  • 🇭🇺Hungary mxr576 Hungary

    Added related config split issue that swtiched to event subscribers.

  • 🇨🇭Switzerland bircher 🇨🇿

    Hi, thanks for digging into this. The real reason is a bug in core I just filed: 🐛 Dispatch config transformation event during site install from configuration Active

    The workaround for now is to import the configuration right after the drupal site install.
    But even when the core issue is addressed Config Split will only get to participate in the second configuration import because it is a module that needs to be installed before it can be used. This is something I am considering addressing for a future version when config split is split into a module and a php library that is available also without being installed. But that is way off topic for now.

  • 🇨🇭Switzerland bircher 🇨🇿

    If you patch drupal core with 🐛 Dispatch config transformation event during site install from configuration Active

    and you add the following to your settings.php it will work as expected:

    // Make config split available before it is installed.
    $class_loader->addPsr4('Drupal\\config_split\\', [ __DIR__ . '/../../modules/contrib/config_split/src']);
    $settings['container_yamls'][] = DRUPAL_ROOT . '/modules/contrib/config_split/config_split.services.yml';
    
  • 🇮🇱Israel heyyo Jerusalem

    I tested #7 unfortunatly I got an error with webprofiler installation which is in my local config split.

    [error]  Error: Interface "Drupal\views\Plugin\views\query\CastSqlInterface" not found in include() (line 10 of /var/www/html/web/core/modules/mysql/src/Plugin/views/query/MysqlCastSql.php) #0 /var/www/html/vendor/composer/ClassLoader.php(576): include()
    #1 /var/www/html/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}()
    #2 [internal function]: Composer\Autoload\ClassLoader->loadClass()
    #3 /var/www/html/web/modules/contrib/webprofiler/src/Compiler/ServicePass.php(76): ReflectionClass->__construct()
    
Production build 0.71.5 2024