diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index 6368b080..74de88f 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -377,6 +377,17 @@ public function onEntityTypeDelete(EntityTypeInterface $entity_type) { // Delete the entity schema. $this->deleteEntitySchemaData($entity_type); + + // Get all storage definitions. + $schema = $this->installedStorageSchema()->getAll(); + + // Delete storage definitions for the deleted entity. + foreach (array_keys($schema) as $storage_definition_name) { + $module_name = substr($storage_definition_name, 0, strpos($storage_definition_name, '.')); + if($module_name == $entity_type->getProvider()) { + $this->installedStorageSchema()->delete($storage_definition_name); + } + } } /** diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index 768d1ef..92bdb80 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -461,19 +461,6 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // Let other modules react. $this->moduleHandler->invokeAll('modules_uninstalled', array($module_list)); - // Clean the storage schema of entities that are gone because their modules - // were uninstalled. - $key_value_store = \Drupal::keyValue('entity.storage_schema.sql'); - $schema = $key_value_store->getAll(); - $entities = array_keys(\Drupal::entityManager()->getDefinitions()); - - foreach ($schema as $item_name => $item) { - $entity_item = substr($item_name, 0, strpos($item_name, '.')); - if(!in_array($entity_item, $entities)) { - $key_value_store->delete($item_name); - } - } - // Flush all persistent caches. // Any cache entry might implicitly depend on the uninstalled modules, // so clear all of them explicitly.