Problem/Motivation
If a module that uses default_content to create some entities is enabled during site install, it will crash during site installation with existing configuration.
I am not sure this is the case for all entities, but I definitely have the issue with files and media.
Steps to reproduce
Create a media that contains a file.
Export to a custom module with default_content.
Have the custom module enabled in your core.extension.yml.
Run a drush site install with exiting configuration:
drush si --existing-config --config-dir=../config/sync -y
Drupal install will crash with an integrity constraint violation, ex:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '8b4eec7f-50e4-48c8-be6e-6869d48a160f' for key 'file_field__uuid__value'
Possible root cause
This seems to be linked to hook_modules_installed() being fired twice:
- first during install_bootstrap_full when isConfigSyncing() is still FALSE
- then again in DefaultContentConfigSubscriber::onConfigImport
Proposed resolution
Do not import content if we are actually in the site install phase (\Drupal\Core\Installer\InstallerKernel::installationAttempted())
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3587418-default_content-skip-import-during-site-install.patch | 645 bytes | renaudcuny |
Issue fork default_content-3587418
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 #3
renaudcuny commentedMerge request submitted, also attaching the patch file for convenience.
Comment #4
sneezycheesy commented@renaudcuny
Are you sure about this patch working? When I use it, I actually have to check that
\Drupal\Core\Installer\InstallerKernel::installationAttempted()has run, otherwise I continue getting the error for duplicate items.