diff --git a/core/lib/Drupal/Core/Config/ConfigManager.php b/core/lib/Drupal/Core/Config/ConfigManager.php index 62e13f4..b5b1c90 100644 --- a/core/lib/Drupal/Core/Config/ConfigManager.php +++ b/core/lib/Drupal/Core/Config/ConfigManager.php @@ -297,7 +297,7 @@ public function getConfigEntitiesToChangeOnDependencyRemoval($type, array $names $dependency_manager = $this->getConfigDependencyManager(); $dependents = $this->findConfigEntityDependentsAsEntities($type, $names, $dependency_manager); $original_dependencies = $dependents; - $delete_uuids = $update_uuids = []; + $delete_uuids = []; $return = [ 'update' => [], @@ -305,6 +305,13 @@ public function getConfigEntitiesToChangeOnDependencyRemoval($type, array $names 'unchanged' => [], ]; + // Create a map of UUIDs to $original_dependencies key so that we can remove + // fixed dependencies. + $uuid_map = []; + foreach ($original_dependencies as $key => $entity) { + $uuid_map[$entity->uuid()] = $key; + } + // Try to fix any dependencies and find out what will happen to the // dependency graph. Entities are processed in the order of most dependent // first. For example, this ensures that Menu UI third party dependencies on @@ -341,13 +348,8 @@ public function getConfigEntitiesToChangeOnDependencyRemoval($type, array $names } if ($fixed) { // Remove the fixed dependency from the list of original dependencies. - foreach ($original_dependencies as $key => $entity) { - if ($entity->uuid() == $dependent->uuid()) { - unset($original_dependencies[$key]); - } - } + unset($original_dependencies[$uuid_map[$dependent->uuid()]]); $return['update'][] = $dependent; - $update_uuids[] = $dependent->uuid(); } } // If the entity cannot be fixed then it has to be deleted. @@ -360,8 +362,8 @@ public function getConfigEntitiesToChangeOnDependencyRemoval($type, array $names } // Use the lists of UUIDs to filter the original list to work out which // configuration entities are unchanged. - $return['unchanged'] = array_filter($original_dependencies, function ($dependent) use ($delete_uuids, $update_uuids) { - return !(in_array($dependent->uuid(), $delete_uuids) || in_array($dependent->uuid(), $update_uuids)); + $return['unchanged'] = array_filter($original_dependencies, function ($dependent) use ($delete_uuids) { + return !(in_array($dependent->uuid(), $delete_uuids)); }); return $return; diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayBaseTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayBaseTest.php index 3804c2a..ec1a55c 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayBaseTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityDisplayBaseTest.php @@ -4,7 +4,6 @@ use Drupal\comment\Entity\CommentType; use Drupal\Core\Entity\Entity\EntityViewDisplay; -use Drupal\Core\Entity\EntityInterface; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\KernelTests\KernelTestBase;