diff --git a/core/lib/Drupal/Core/Config/StorageComparer.php b/core/lib/Drupal/Core/Config/StorageComparer.php index 0b5c3cd..ce6f609 100644 --- a/core/lib/Drupal/Core/Config/StorageComparer.php +++ b/core/lib/Drupal/Core/Config/StorageComparer.php @@ -205,33 +205,25 @@ protected function addChangelistUpdate() { */ protected function addChangelistRename() { // Renames will be present in both create and delete lists. - $create_uuids = array(); - $create_data = array_diff($this->sourceNames, $this->targetNames); - if (empty($create_data)) { + if (empty($this->getChangelist('create')) || empty($this->getChangelist('delete'))) { return; } - foreach ($this->getSourceStorage()->readMultiple($create_data) as $create_id => $data) { + + $create_uuids = array(); + foreach ($this->getSourceStorage()->readMultiple($this->getChangelist('create')) as $id => $data) { if (isset($data['uuid'])) { - $create_uuids[$data['uuid']] = $create_id; + $create_uuids[$data['uuid']] = $id; } } - $delete_data = array_diff($this->targetNames, $this->sourceNames); - if (empty($create_uuids) || empty($delete_data)) { + if (empty($create_uuids)) { return; } + $renames = array(); - foreach ($this->getTargetStorage()->readMultiple($delete_data) as $delete_id => $data) { + foreach ($this->getTargetStorage()->readMultiple($this->getChangelist('delete')) as $id => $data) { if (isset($data['uuid']) && isset($create_uuids[$data['uuid']])) { - $renames[] = $delete_id . '::' . $create_uuids[$data['uuid']]; - - $key = array_search($create_uuids[$data['uuid']], $this->changelist['create']); - if ($key !== FALSE && isset($this->changelist['create'][$key])) { - unset($this->changelist['create'][$key]); - } - $key = array_search($delete_id, $this->changelist['delete']); - if ($key !== FALSE && isset($this->changelist['delete'][$key])) { - unset($this->changelist['delete'][$key]); - } + $renames[] = $id . '::' . $create_uuids[$data['uuid']]; + $this->removeFromChangelistsByUuid($data['uuid']); } } // Reverse the array until we can manage dependencies. @@ -239,6 +231,18 @@ protected function addChangelistRename() { } /** + * Removes changes from all lists for the given UUID. + */ + protected function removeFromChangelistsByUuid($uuid) { + foreach ($this->getChangelist() as $op => $data) { + $key = array_search($uuid, $data); + if ($key !== FALSE) { + unset($this->changelist[$op][$key]); + } + } + } + + /** * {@inheritdoc} */ public function reset() {