Configuration system doesn't allow importing a single item from a non-default collection.
Given minimal Drupal installation with config and locale modules installed. Let's add new language (for instance Russian) and download its updates. Then go to admin/config/development/configuration/full/export and get full config archive or just run drush cex sync
. In the produced config you will find a folder named language.ru (ru stands for Russian language in this example) where translated configs are placed.
Now try to import any single item back to active storage from this page admin/config/development/configuration/single/import or using drush cim sync --partial
, ensure some config item(s) are modified for the default collection.
I will use this one as example:
system.maintenance.yml
message: '@site is currently under maintenance. We should be back shortly. Thank you for your patience!'
langcode: en
The following errors occur before confirmation step:
Notice: Undefined index: language.ru in Drupal\config\StorageReplaceDataWrapper->listAll() (line 131 of core/modules/config/src/StorageReplaceDataWrapper.php).
Warning: array_keys() expects parameter 1 to be array, null given in Drupal\config\StorageReplaceDataWrapper->listAll() (line 131 of core/modules/config/src/StorageReplaceDataWrapper.php).
After submitting the form - nothing changes in default collection and all items in the language.ru collection are broken (they could be empty or contain data from the default collection). It can be verified by exporting full config once again and compare with the original one.
This issue makes absolutely impossible to rely on config import/export system.
Scenario 1.
admin/config/regional/language/add
.admin/config/development/configuration/single/export
.admin/config/development/configuration/single/import
Expected results: Changes are saved w/o errors.
Actual results: Changes not saved, errors displayed, all language.ru configs filled with data from default language settings:
Error message
Notice: Undefined index: language.ru in Drupal\config\StorageReplaceDataWrapper->listAll() (line 131 of core/modules/config/src/StorageReplaceDataWrapper.php).
Warning: array_keys() expects parameter 1 to be array, null given in Drupal\config\StorageReplaceDataWrapper->listAll() (line 131 of core/modules/config/src/StorageReplaceDataWrapper.php).
Notice: Undefined index: language.ru in Drupal\config\StorageReplaceDataWrapper->listAll() (line 131 of core/modules/config/src/StorageReplaceDataWrapper.php).
Warning: array_keys() expects parameter 1 to be array, null given in Drupal\config\StorageReplaceDataWrapper->listAll() (line 131 of core/modules/config/src/StorageReplaceDataWrapper.php).
Notice: Undefined index: language.ru in Drupal\config\StorageReplaceDataWrapper->listAll() (line 131 of core/modules/config/src/StorageReplaceDataWrapper.php).
Warning: array_keys() expects parameter 1 to be array, null given in Drupal\config\StorageReplaceDataWrapper->listAll() (line 131 of core/modules/config/src/StorageReplaceDataWrapper.php).
Scenario 2.
drush en config locale
)admin/config/regional/language/add
.drush config-export sync
to export current configs.drush config-import sync --partial
to update active config.drush config-export sync
to export configs again and see the differences.Expected results: The active configuration is identical to the configuration in the export directory.
Actual results: Changes to default collection not saved, non-default collection items overriden by data from default collection corresponding items, errors displayed:
$ drush config-import sync --partial
Collection Config Operation
system.maintenance update
Import the listed configuration changes? (y/n): y
array_keys() expects parameter 1 to be array, null given StorageReplaceDataWrapper.php:131 [warning]
array_keys() expects parameter 1 to be array, null given StorageReplaceDataWrapper.php:131 [warning]
array_keys() expects parameter 1 to be array, null given StorageReplaceDataWrapper.php:131 [warning]
array_keys() expects parameter 1 to be array, null given StorageReplaceDataWrapper.php:131 [warning]
array_keys() expects parameter 1 to be array, null given StorageReplaceDataWrapper.php:131 [warning]
The configuration was imported successfully. [success]
Scenario 3. (Thanks to @Arla for idea given in #7)
admin/config/regional/language/add
.drush config-edit system.maintenance
, edit and save changes.Expected results: Changes are saved w/o errors.
Actual results: Changes not saved and errors displayed:
$ drush config-edit system.maintenance
Collection Config Operation
system.maintenance update
Import the listed configuration changes? (y/n): y
array_keys() expects parameter 1 to be array, null given StorageReplaceDataWrapper.php:131 [warning]
array_keys() expects parameter 1 to be array, null given StorageReplaceDataWrapper.php:131 [warning]
array_keys() expects parameter 1 to be array, null given StorageReplaceDataWrapper.php:131 [warning]
array_keys() expects parameter 1 to be array, null given StorageReplaceDataWrapper.php:131 [warning]
array_keys() expects parameter 1 to be array, null given StorageReplaceDataWrapper.php:131 [warning]
The configuration was imported successfully. [success]
Note: If you get errors like this (Not reproducable prior to core 8.3.x):
Drupal\Core\Config\ConfigImporterException: There were errors validating the config synchronization. in [error]
Drupal\Core\Config\ConfigImporter->validate() (line 728 of core/lib/Drupal/Core/Config/ConfigImporter.php).
The import failed due for the following reasons: [error]
Site UUID in source storage does not match the target storage.
You should sync system.site uuid between collections using sql query or shell command:
$ head -n1 PATH_TO_SYNC/system.site.yml >> PATH_TO_SYNC/language/YOUR_LANGUAGE/system.site.yml
$ drush config-import sync -y
Fix createCollection method of StorageReplaceDataWrapper class to valid object with correct collection.
Find out a way to allow importing of the config items from any collection using UI and drush cim
.
Fixed
9.5
Last updated
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.