Problem/Motivation
Issue #3544715: Add oop support to hooks currently supported by themes brought us theme OOP hooks. To do so ConfigInstaller has to rebuild the container, like ModuleInstaller does.
What was forgotten there was duplicating the ::reinjectMe() codepath from modules to themes too in the ConfigImporter.
The result: All sorts of likely hard to spot container DI issues on cli install, likely breaking the install (thus major).
- This report: retrieving a synthetic service ("kernel") throws
- the other report (#3569677: 3544715 breaks RequestStack on existing-config-install): some services have an empty RequestStack
Steps to reproduce
- Prepare a site with an existing configuration export.
- Ensure the configuration includes items that trigger theme-related updates. In our case, this error is triggered when webform.webform_options.* (provided by the Webform module) is being imported.
- Run the installation command: drush site:install --existing-config
Proposed resolution
In ConfigImporter, do the same container rebuild handling for themes that is done for modules.
Remaining tasks
- Write a test
- ConfigImporterTest seems to be the place for it. This class currently has no test for the ModuleHandler ::reinjectMe code path.
- There is ::testInstallBaseAndSubThemes though, which might be nice to extend.
- Test inspired by this report: $container->get('kernel')
- Test inspired by the dup report: $container->get('request_stack') ... contains request
- Decide whether that other line from the module codepath must be duplicated and tested too: $this->moduleHandler->loadAll();
- review, commit, stop having pain
Original report
This issue occurs in Drupal 11.3.1, while it does not occur in Drupal 11.2.10.
When performing a non-interactive installation from existing configuration (e.g., using drush site:install --existing-config), the following error may occur during the configuration import process:
You have requested a synthetic service ("kernel"). The DIC does not know how to construct this service.
In Drupal 11.3, the ThemeInstaller (theme_installer service) was updated. It appears that DrupalKernel::updateThemes() now triggers a container re-initialization.
Within ConfigImporter::processExtension(), after the theme_installer service is executed, it seems necessary to re-inject the services (similar to how it is handled for modules) to prevent the service container from losing track of synthetic services like the kernel.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 3564735-18.patch | 1.04 KB | hmdnawaz |
Issue fork drupal-3564735
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
Comment #2
kazuko.murata commentedComment #4
nicxvan commentedThank you for finding this!
This will likely need a test too.
Comment #5
kazuko.murata commentedI’ve opened a Merge Request to fix this bug and confirmed via manual testing that it works as expected.
I’d appreciate it if you could review the MR and let me know if there’s anything else I should do.
Comment #6
smustgrave commentedThanks for reporting.
Summary appears to be missing a few sections from the template. Most importantly the proposed solution section.
Believe #4 meant we will need a test case or new assertion on an existing test that shows the problem described here.
Comment #8
nicxvan commentedThere was a duplicate of #3569677: 3544715 breaks RequestStack on existing-config-install
Please restore the issue summary. I wonder if this is a drush issue?
What does drush do under the hood with that command?
Comment #9
geek-merlinHere we go with an updated IS. Which should make clear that this is not a drush issue.
Comment #10
geek-merlinMade the title more general to not provoke more dups.
Comment #11
geek-merlinComment #12
geek-merlinComment #13
heddnI can confirm the fixes here resolve an issue with a functional test I had that was installing existing config. No drush was involved, just pure phpunit.
Comment #14
geek-merlin@heddn Can u share that test?
Comment #15
heddnhttps://github.com/heddn/install_profile/blob/main/web/profiles/install_...
Comment #16
jeroentRan into this problem during a site install (drush si --existing-config), which resulted in the following error:
MR 14169 fixed the problem for me.
Comment #17
steinmb commentedOur Behat pipeline failed installing from existing config on D11.3.x.
The suggested patch fixed it.
Comment #18
hmdnawaz commentedPatch from the MR
Comment #20
phenaproximaWrote a test which, at least locally, fails as expected without the fix. This is ready for review.
Comment #21
balsamaUsing this patch in a custom Drupal CMS Project scaffold and I can confirm functionally it fixes the exceptions thrown during install from config.
Comment #22
alexpottCommitted and pushed 24b60a5c648 to main and a76b3fa0cb2 to 11.x and 5226fc8ae10 to 11.3.x. Thanks!
Comment #26
alexpott