diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index 74de88f..d9d7bee 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -383,8 +383,8 @@ public function onEntityTypeDelete(EntityTypeInterface $entity_type) { // 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()) { + $entity_type_id = substr($storage_definition_name, 0, strpos($storage_definition_name, '.')); + if($entity_type_id == $entity_type->id()) { $this->installedStorageSchema()->delete($storage_definition_name); } } diff --git a/core/modules/system/src/Tests/Entity/EntitySchemaTest.php b/core/modules/system/src/Tests/Entity/EntitySchemaTest.php index 695c0e8..46245f5 100644 --- a/core/modules/system/src/Tests/Entity/EntitySchemaTest.php +++ b/core/modules/system/src/Tests/Entity/EntitySchemaTest.php @@ -145,10 +145,13 @@ public function testModifyingTranslatableColumnSchema() { public function testCleanUpStorageDefinition() { // Find all the entity types provided by the entity_test module and install // the schema for them. + + $entity_type_ids =[]; $entities = \Drupal::entityManager()->getDefinitions(); foreach ($entities as $name => $definition) { if ($definition->getProvider() == 'entity_test') { $this->installEntitySchema($name); + $entity_type_ids[] = $name; }; } @@ -161,16 +164,17 @@ public function testCleanUpStorageDefinition() { $item_count = 0; - // Count the storage definitions that begin with entity_test. + // Count the storage definitions that come from entity types provided by + // the entity_test module. foreach (array_keys($schema) as $storage_definition_name) { $entity_item = substr($storage_definition_name, 0, strpos($storage_definition_name, '.')); - if ($entity_item == 'entity_test') { + if (in_array($entity_item, $entity_type_ids)) { $item_count++; } } // Ensure that all storage definitions have been removed from the schema. - $this->assertEqual($item_count, 0, 'After uninstalling entity_test module the schema still contains fields for the the entity_test entity.'); + $this->assertEqual($item_count, 0, 'After uninstalling entity_test module the schema still contains fields from entities provided by this module.'); } }