diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index 4a09e40..5d1bc29 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -367,9 +367,14 @@ public function onEntityTypeDelete(EntityTypeInterface $entity_type) { $this->originalDefinitions = $field_storage_definitions; $table_mapping = $this->storage->getTableMapping($field_storage_definitions); foreach ($field_storage_definitions as $field_storage_definition) { + // If we have a field having dedicated storage we need to drop it, + // otherwise we just remove the related schema data. if ($table_mapping->requiresDedicatedTableStorage($field_storage_definition)) { $this->deleteDedicatedTableSchema($field_storage_definition); } + elseif ($table_mapping->allowsSharedTableStorage($field_storage_definition)) { + $this->deleteFieldSchemaData($field_storage_definition); + } } $this->originalDefinitions = NULL; @@ -377,17 +382,6 @@ 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) { - $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); - } - } } /**