diff --git a/core/lib/Drupal/Core/Config/ConfigManager.php b/core/lib/Drupal/Core/Config/ConfigManager.php index ad9f268..4a6ec16 100644 --- a/core/lib/Drupal/Core/Config/ConfigManager.php +++ b/core/lib/Drupal/Core/Config/ConfigManager.php @@ -331,9 +331,9 @@ public function getConfigEntitiesToChangeOnDependencyRemoval($type, array $names } } // Now that we've fixed all the possible dependencies the remaining need to - // be deleted. Reverse the array so that entities are removed in the correct - // order of dependence. For example, this ensures that fields are removed - // before field storages. + // be deleted. Reverse the deletes so that entities are removed in the + // correct order of dependence. For example, this ensures that fields are + // removed before field storages. $return['delete'] = array_reverse($dependents); $delete_uuids = array_map(function($dependent) { return $dependent->uuid(); @@ -382,8 +382,8 @@ public function getConfigCollectionInfo() { * or 'content'. * @param array $names * The specific names to check. If $type equals 'module' or 'theme' then it - * should be a list of module names or theme names. In the case of entity it - * should be a list of full configuration object names. + * should be a list of module names or theme names. In the case of 'config' + * or 'content' it should be a list of configuration dependency names. * * @return bool * TRUE if the entity has changed as a result of calling the diff --git a/core/lib/Drupal/Core/Config/ConfigManagerInterface.php b/core/lib/Drupal/Core/Config/ConfigManagerInterface.php index 1bea217..a9907f4 100644 --- a/core/lib/Drupal/Core/Config/ConfigManagerInterface.php +++ b/core/lib/Drupal/Core/Config/ConfigManagerInterface.php @@ -111,8 +111,8 @@ public function getConfigDependencyManager(); * or 'content'. * @param array $names * The specific names to check. If $type equals 'module' or 'theme' then it - * should be a list of module names or theme names. In the case of entity it - * should be a list of full configuration object names. + * should be a list of module names or theme names. In the case of 'config' + * or 'content' it should be a list of configuration dependency names. * * @return \Drupal\Core\Config\Entity\ConfigEntityDependency[] * An array of configuration entity dependency objects. @@ -127,8 +127,8 @@ public function findConfigEntityDependents($type, array $names); * or 'content'. * @param array $names * The specific names to check. If $type equals 'module' or 'theme' then it - * should be a list of module names or theme names. In the case of entity it - * should be a list of full configuration object names. + * should be a list of module names or theme names. In the case of 'config' + * or 'content' it should be a list of configuration dependency names. * * @return \Drupal\Core\Config\Entity\ConfigEntityInterface[] * An array of dependencies as configuration entities. @@ -136,24 +136,26 @@ public function findConfigEntityDependents($type, array $names); public function findConfigEntityDependentsAsEntities($type, array $names); /** - * Determines which config entities need to updated or deleted on removal of... + * Lists which config entities to update and delete on removal of a dependency. * * @param string $type * The type of dependency being checked. Either 'module', 'theme', 'config' * or 'content'. * @param array $names * The specific names to check. If $type equals 'module' or 'theme' then it - * should be a list of module names or theme names. In the case of entity it - * should be a list of full configuration object names. + * should be a list of module names or theme names. In the case of 'config' + * or 'content' it should be a list of configuration dependency names. * @param bool $dry_run * If set to FALSE the entities returned in the list of updates will * modified. In order to make the changes the caller needs to save them. If * set to TRUE the entities returned will not be modified. * * @return array - * An array with two keys: 'update' and 'delete'. The value of each is a - * list of configuration entities that will have that action applied when - * the supplied dependencies are removed. + * An array with the keys: 'update', 'delete' and 'unchanged'. The value of + * each is a list of configuration entities that need to have that action + * applied when the supplied dependencies are removed. Updates need to be + * processed before deletes. The order of the deletes is significant and + * must be processed in the order. */ public function getConfigEntitiesToChangeOnDependencyRemoval($type, array $names, $dry_run = TRUE); diff --git a/core/modules/config/src/Tests/ConfigDependencyTest.php b/core/modules/config/src/Tests/ConfigDependencyTest.php index bdc1161..047a20d 100644 --- a/core/modules/config/src/Tests/ConfigDependencyTest.php +++ b/core/modules/config/src/Tests/ConfigDependencyTest.php @@ -253,10 +253,10 @@ public function testConfigEntityUninstall() { // Do a dry run using // \Drupal\Core\Config\ConfigManager::getConfigEntitiesToChangeOnDependencyRemoval(). $config_entities = $config_manager->getConfigEntitiesToChangeOnDependencyRemoval('module', ['node']); - $this->assertEqual($entity1->uuid(), $config_entities['delete'][1]->uuid(), 'Entity 1 will be deleted.'); + $this->assertEqual($entity1->uuid(), $config_entities['delete'][0]->uuid(), 'Entity 1 will be deleted.'); $this->assertEqual($entity2->uuid(), reset($config_entities['update'])->uuid(), 'Entity 2 will be updated.'); $this->assertEqual($entity3->uuid(), reset($config_entities['unchanged'])->uuid(), 'Entity 3 is not changed.'); - $this->assertEqual($entity4->uuid(), $config_entities['delete'][0]->uuid(), 'Entity 4 will be deleted.'); + $this->assertEqual($entity4->uuid(), $config_entities['delete'][1]->uuid(), 'Entity 4 will be deleted.'); // Perform the uninstall. $config_manager->uninstall('module', 'node'); @@ -319,8 +319,8 @@ public function testContentEntityDelete() { $entity3->save(); $config_entities = $config_manager->getConfigEntitiesToChangeOnDependencyRemoval('content', [$content_entity->getConfigDependencyName()]); - $this->assertEqual($entity1->uuid(), $config_entities['delete'][1]->uuid(), 'Entity 1 will be deleted.'); - $this->assertEqual($entity2->uuid(), $config_entities['delete'][0]->uuid(), 'Entity 2 will be deleted.'); + $this->assertEqual($entity1->uuid(), $config_entities['delete'][0]->uuid(), 'Entity 1 will be deleted.'); + $this->assertEqual($entity2->uuid(), $config_entities['delete'][1]->uuid(), 'Entity 2 will be deleted.'); $this->assertTrue(empty($config_entities['update']), 'No dependencies of the content entity will be updated.'); $this->assertTrue(empty($config_entities['unchanged']), 'No dependencies of the content entity will be unchanged.'); }