diff --git a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php index c4b17c5..fb28928 100644 --- a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php @@ -462,6 +462,12 @@ public function delete(array $entities) { ->execute(); } + if ($this->dataTable) { + $this->database->delete($this->dataTable) + ->condition($this->idKey, $ids, 'IN') + ->execute(); + } + // Reset the cache as soon as the changes have been applied. $this->resetCache($ids); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiTest.php index 57f9355..f885c31 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiTest.php @@ -90,6 +90,16 @@ protected function assertCRUD($entity_type, UserInterface $user1) { $all = entity_load_multiple($entity_type); $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', array('%entity_type' => $entity_type))); + + // Verify that all data got deleted. + $definition = \Drupal::entityManager()->getDefinition($entity_type); + $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {' . $definition['base_table'] . '}')->fetchField(), 'Base table was emptied'); + if (isset($definition['data_table'])) { + $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {' . $definition['data_table'] . '}')->fetchField(), 'Data table was emptied'); + } + if (isset($definition['revision_table'])) { + $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {' . $definition['revision_table'] . '}')->fetchField(), 'Data table was emptied'); + } } /**