Steps to reproduce
* Install a site using a profile in English
* Enable locale, language
* Add a second language e.g. Swedish
* Set default language to Swedish
* Export configuration
* Install site again using same profile
* Config import configuration
* You will see (or at least I did):
Synchronized configuration: update ...
Finalizing configuration synchronization. [ok]
The import failed due for the following reasons:
Unexpected error during import with operation create for shortcut.set.default: SQLSTATE[23000]: Integrity constraint
violation: 1062 Duplicate entry 'sv-5' for key 'PRIMARY': INSERT INTO {locales_target} (lid,
language, translation, customized) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1,
:db_insert_placeholder_2, :db_insert_placeholder_3); Array
...
| Comment | File | Size | Author |
|---|
Comments
Comment #2
dasj19 commentedThis affects me as well.
I do imports via drush: drush cim
The output is:
The import failed due for the following reasons: [error]
Unexpected error during import with operation update for block.block.bartik_search: SQLSTATE[23000]:
Integrity constraint violation: 1062 Duplicate entry 'da-32' for key 'PRIMARY':
INSERT INTO {locales_target} (lid, language, translation, customized) VALUES (:db_insert_placeholder_0,
:db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array
(
[:db_insert_placeholder_0] => 32
[:db_insert_placeholder_1] => da
[:db_insert_placeholder_2] => Søg
[:db_insert_placeholder_3] => 1
)
Comment #3
kporras07 commentedSame error here. I can't import configuration on this scenario.
Comment #4
mpp commentedSame error on 8.7.0-beta2.
Comment #5
mpp commentedInitially we did a
drush site_install&&drush cim. I noticed that all translations were being imported with the 'en' key so I assume that the languages (nl, fr, de, ...) were not yet imported.We got it working by using
drush site_install --existing-config.Comment #8
kalidasan commentedSame error while upgrading to 8.9.2 (Importing config from 8.6.2)
Comment #9
dimas11 commentedSame error on v.8.9.5
Type: config_import
Message: Drupal\Core\Config\ConfigException: Errors occurred during import in Drush\Drupal\Commands\config\ConfigImportCommands->doImport() (line 250 of /var/www/vendor/drush/drush/src/Drupal/Commands/config/ConfigImportCommands.php).
Comment #11
leksat commentedCurrently getting the same on Drupal 9.2 to 9.3 update.
Debugged it a little:
-
system_post_update_sort_all_configsaves a lot of config objects. One of them is a view.-
views_post_update_sort_identifiertries to save the same view object and here's where it breaks.Looks like
\Drupal\locale\LocaleConfigManager::$translationshas outdated data when the second post-update happens. But I don't know why...Comment #12
leksat commentedCannot dive deeper into this now. Attaching my current quick-fix.
Comment #13
leksat commentedWhile the above workaround worked, I start think that maybe

views_post_update_sort_identifieris the real reason. Because all views were translated to German 😂Other config objects seem to be okay. Still English 💪
Comment #14
leksat commentedI have a guess that all my issues are somehow related to the fact that I have "Enable interface translation to English" option enabled at
/admin/config/regional/language/edit/en.Does anyone from this issue have this option enabled as well?
Comment #16
thomjjames commentedHi,
Also getting this with drush updatedb for a Drupal 8.x to 9.3.3 update. I don't have allow English translation enabled but the patch #12 does fix it for me & the database updates run without error. Thanks!
Tom
Comment #18
broonWe ran into the same issue on an installation with 9.2.9 after adding a few new languages.
Strange enough, this didn't happen when adding other languages earlier (Polish, Russian) but only now with Ukranian and Turkish.
Adding the patch from #12 to our composer.json does not fix the problem, though. The same error messages still appear when running
drush cim.For example, Backup&Migrate is active. The string "Private Files Directory" appears twice in that module, once for destination and once for source. By changing the config files, I was able to confirm, that the first translation (destination) ran through while the second one causes an error like this:
What puzzles me is value for
[:db_insert_placeholder_1]. That should be "uk", I believe, because the phrase in placeholder 2 is Ukranian.Comment #19
broonAfter a while of debugging and testing, I found the issue to be that during the same single process of "drush cim" both a new language and config translations for that language are imported.
I do not know about the inner mechanics of config import, but it seems the system is not (yet) aware of that language and thus unable to import a translation for that language.
I stumbled upon that, because we do have the module "Entity Language Fallback" installed. This defines a chain of fallback languages for entities if a specific translation is not available. That's (probably) why in my post above, the system is trying to insert a Ukrainian string as English translation because English is set to be the fallback language for Ukrainian.
The solution in our case was to take advantage of the set pipeline, where "drush updb" is run before "drush cim". By adding an update hook into the custom configuration module, we were able to import the language first (during "drush updb") and only then import the translations (during "drush cim").