Problem/Motivation
When a new language is created in the user interface, \Drupal\language\Config\LanguageConfigFactoryOverride::installLanguageOverrides()
is called with the language code of the newly created language so that all language overrides for that language that may be available in any shipped modules or, in particular, the install profile get installed.
If a language is being created during a config sync, this should not happen, however, because any language overrides that should end up in the target storage should be part of the sync.
But on top of just being unnecessary CPU this actually causes a problem resulting in the entire config sync failing: If a module or profile ships a language override for a config entity and that override will also be created as part of the config sync, then a
Deleted and replaced configuration entity
error will be raised.
Steps to reproduce
- Have a site without the German language and a with a body field on the article node type
- Add the German language and translate the body field (for example using Config Translation)
- Export the configuration and attempt to import it on another instance of the site
You should see something like
+-------------+----------------------------------------+-----------+
| Collection | Config | Operation |
+-------------+----------------------------------------+-----------+
| | language.entity.de | Create |
| language.de | field.field.node.article.body | Create |
+-------------+----------------------------------------+-----------+
as output of drush cim
You will be greeted with:
The import failed due to the following reasons:
Deleted and replaced configuration entity "field.field.node.article.body"
Instead of the import succeeding.
Proposed resolution
Explicitly check that no config sync is happening in \Drupal\language\Entity\ConfigurableLanguage::postSave()
before calling \Drupal\language\Config\LanguageConfigFactoryOverride::installLanguageOverrides()
.
Remaining tasks
User interface changes
-
Introduced terminology
-
API changes
-
Data model changes
-
Release notes snippet