Problem/Motivation
Running drush cim -y after drush si --existing-config -y throws a fatal TypeError:
TypeError: Drupal\config_split\Config\ConfigSorter::sortDeep():
Argument #2 ($model) must be of type array, false given, called in
/docroot/modules/contrib/config_split/src/Config/ConfigPatchMerge.php on line 96
in Drupal\config_split\Config\ConfigSorter->sortDeep()
(line 174 of config_split/src/Config/ConfigSorter.php)
Steps to reproduce
- Fresh drush si --existing-config -y on a site with config_split enabled
- Run drush cim -y immediately after
Proposed resolution
Guard against the false return value from read() before calling sortDeep():
if ($this->active->exists($name)) {
$activeData = $this->active->read($name);
if (is_array($activeData)) {
$data = $this->sortDeep($data, $activeData);
}
}
Issue fork config_split-3601197
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 #2
dkmishra commentedI cannot reproduce this with only
drush si --existing-config -yfollowed bydrush cim -yon config_split 2.0.2 / Drupal 11.3.11 / Drush 13.7.3. Could you provide the relevant split configuration, the affected config name, and whether any config_split.* files or partial split configuration are involved? There may be a specific setup detail missing from the reproduction steps.Comment #5
beunerd commented@dkmishra I was able to reproduce.
ConfigSorter::sort()assumesread()returns an array wheneverexists()isTRUE, butread()can still returnFALSE(e.g. right afterdrush si --existing-config), which throws the TypeError.I added an MR that skips sorting when
read()isn't an array (and included a test with a mocked storage).Comment #6
peri22 commentedComment #7
peri22 commentedConfirmed on the current '2.0.x' HEAD. This is tricky to reproduce because 'CachedStorage::exists()' bypasses the cache, while 'read()' answers from it (and can return 'FALSE' for missing objects too). When they disagree, the error occurs. I managed to reproduce the reported 'TypeError' using real storages (no mocks) in two ways, and MR !65 fixes both.
The existing sorter test stays green, 'phpcs' is clean, the MR applies to today's HEAD, and pipeline 927451 is green across all jobs. RTBC.