Closed vever001 closed 8 months ago
I have just encountered this error in our environment, and only on sites that are set to Swedish where I get the following errors:
[warning] Undefined array key "language.en" ConfigImporter.php:353
[warning] Trying to access array offset on value of type null ConfigImporter.php:353
The next time I import configuration it works without any errors, but because the error occurs the first time it disturbs our deploy process.
Is there any way to fix this without writing post-update hooks?
Have the same problem,
TypeError: array_diff(): Argument #2 must be of type array, null given in array_diff() (line 353 of /web/core/lib/Drupal/Core/Config/ConfigImporter.php)."
I try to disable the module by drush cim
after on UI I can see something like
If I run drush cim
a second time it works without issue
Quick update: Running the config import from UI (at /admin/config/development/configuration) works without issue, so this looks specific to drush.
I think drush_backend_batch_process
should be triggered at the very end of ConfigImportCommands::doImport
(not in the middle of a sync step), similar to what happens from UI: first all configs get imported, only then batch operations run. Doing this seems to solve the issue.
I'll open a PR shortly.
Seems reasonable to me to run batch at the end, similar to how form api does it. Any thoughts @claudiu-cristea or @alexpott or @bircher?
@weitzman @vever001 The explanation is, indeed, reasonable. As the PR doesn't have tests I'll do a manual test with the code that required #5714 plus the PR
Tested the #5869 PR, see may comment over there.
Describe the bug After updating to drush 12, and PR https://github.com/drush-ops/drush/pull/5714 included in drush 12.1.3 specifically, it looks like there can be a side effect with language config collections in some situations.
I am getting this error on a multilingual site during
config:import
:At the beginning of
config:import
,locale_system_update
gets called if modules need to be enabled. This can cause some new config collections to be added (during the batch process that https://github.com/drush-ops/drush/pull/5714 added) and if so, leads to the error above. So initially, we need a language but without any corresponding config collection records (in theconfig
table).This may not be an issue with drush itself but drupal core.
To Reproduce In my case I have an
mk
language in drupal and no correspondinglanguage.mk
config collection (in theconfig
table) initially. Then when runningconfig:import
, devel gets enabled which imports config translations. See full log below.This may not be easy to reproduce from a clean setup... but I'll try to do it when I have some time.
Expected behavior No error
Actual behavior An error
Workaround I noticed calling
locale_config_batch_update_components
beforeconfig:import
runs (in a post-update hook for example) prevents the issue to happen because it will create several records with the language.mk collection in config table (but it is not guaranteed to do so).System Configuration
Additional information Here is the relevant output from config:import: