Skip to content
Snippets Groups Projects

Fix proposal for #3435910

Open Gaël Gosset requested to merge issue/config_split-3435910:3435910 into 2.0.x
1 unresolved thread
Files
3
+ 39
3
@@ -409,6 +409,34 @@ public function splitPreview(ImmutableConfig $config, StorageInterface $transfor
}
}
}
// Handle the case where some config entities have to exist in default
// config but not in splitted one.
// We get the collection names from default config, as some collections
// could be totally emptied in split config, thus not found by
// DatabaseStorage::getAllCollectionNames().
foreach (array_merge(
[StorageInterface::DEFAULT_COLLECTION],
$this->sync->getAllCollectionNames()
) as $collection) {
$syncCollection = $preparedSync->createCollection($collection);
$sourceCollection = $source->createCollection($collection);
$storageCollection = $transforming->createCollection($collection);
$splitCollection = $splitStorage->createCollection($collection);
$partialList = array_filter($syncCollection->listAll(), function ($name) use ($partialSplitList, $completelySplit) {
// Check for wildcards. But skip config which is already split.
return !in_array($name, $completelySplit) && self::inFilterList($name, $partialSplitList);
});
foreach ($partialList as $name) {
if (!$sourceCollection->exists($name) && $syncCollection->exists($name)) {
$sync = $syncCollection->read($name);
$this->createPatch($name, [FALSE], $sync, $splitCollection);
$storageCollection->write($name, $sync);
}
}
}
}
// Now special case the extensions.
@@ -449,9 +477,17 @@ public function mergeSplit(ImmutableConfig $config, StorageInterface $transformi
$diff = ConfigPatch::fromArray($data);
if ($storage->exists($name)) {
// Skip patches for config that doesn't exist in the storage.
$data = $storage->read($name);
$data = $this->patchMerge->mergePatch($data, $diff->invert(), $name);
$storage->write($name, $data);
if ((($diff->getRemoved()[0]) ?? NULL) === FALSE) {
// It means that this config entity which exists by default
// should not exist when the split is enabled.
// @see \Drupal\config_split\ConfigSplitManager::splitPreview().
$storage->delete($name);
}
else {
$data = $storage->read($name);
$data = $this->patchMerge->mergePatch($data, $diff->invert(), $name);
$storage->write($name, $data);
}
}
}
else {
Loading