Modules that create config cannot be installed alongside modules that depend on that config

Created on 3 January 2025, 4 months ago

Problem/Motivation

Experience Builder creates config at install time in hook_rebuild(). It also has tests that install submodules that depend on that config. These tests fail in 11.x because the config is not created in time, even if container_rebuild_required: true is set.

Steps to reproduce

Run Drupal\Tests\experience_builder\Functional\TranslationTest against 11.x.

Proposed resolution

We check validity of the entire config set before grouping the modules:

    // Check the validity of the default configuration. This will throw
    // exceptions if the configuration is not valid.
    $config_installer->checkConfigurationToInstall('module', $module_list);

    // Some modules require a container rebuild before and after install.
    // Group modules such that as many are installed together as possible until
    // one needs a container rebuild.
    $module_groups = [];
    $index = 0;
    foreach ($module_list as $module) {
      // Ensure the container is rebuilt both before and after a module that
      // requires a container rebuild is installed.
      $container_rebuild_required = !empty($module_data[$module]->info['container_rebuild_required']);

Check the validity of each group instead of the whole set at once.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

install system

Created by

🇬🇧United Kingdom longwave UK

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

Comments & Activities

  • Issue created by @longwave
  • 🇬🇧United Kingdom longwave UK

    If I rearrange the code and add container_rebuild_required: true to the submodule that contains the config, then the test passes again. However if this is the solution, it would be nice to be able to trigger a rebuild *after* Experience Builder is installed, instead of *before* any dependency is installed, but I don't think there is a way to do that right now.

  • 🇬🇧United Kingdom catch

    We talked about using the dependency graph in 📌 Consider defaulting requires_container_rebuild to FALSE Active but also why is xb using hook_rebuild() and not hook_install()?

  • 🇬🇧United Kingdom longwave UK

    It creates/manages config entities for all SDCs and block plugins so it needs to react whenever these might change, not just when it is first installed. But perhaps hook_install() will solve the immediate issue, will test.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Production build 0.71.5 2024