diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index 7a9c8a84e19a7e50a94324ffde52ccb9d5508e9a..ad9d17b140dc116b85b7df02329f109b8225dbf2 100644 --- a/core/modules/entity/entity.module +++ b/core/modules/entity/entity.module @@ -47,9 +47,8 @@ function entity_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) { * Implements hook_entity_bundle_delete(). */ function entity_entity_bundle_delete($entity_type, $bundle) { - $entity_info = entity_get_info('entity_display'); - // Remove entity displays of the deleted bundle. + $entity_info = entity_get_info('entity_display'); $ids = config_get_storage_names_with_prefix('entity.display.' . $entity_type . '.' . $bundle); foreach ($ids as &$id) { $id = ConfigStorageController::getIDFromConfigName($id, $entity_info['config_prefix']); @@ -57,6 +56,7 @@ function entity_entity_bundle_delete($entity_type, $bundle) { entity_delete_multiple('entity_display', $ids); // Remove entity form displays of the deleted bundle. + $entity_info = entity_get_info('entity_form_display'); $ids = config_get_storage_names_with_prefix('entity.form_display.' . $entity_type . '.' . $bundle); foreach ($ids as &$id) { $id = ConfigStorageController::getIDFromConfigName($id, $entity_info['config_prefix']); diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php index 4337abdc327741b9048d8c79f1e6c3f8700b9b67..6a0ddc55d98c9449e26c9d2a5c87270259483fc5 100644 --- a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php +++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php @@ -206,9 +206,10 @@ public function testRenameDeleteBundle() { $this->installSchema('system', array('variable')); $this->installSchema('node', array('node')); - // Create a node bundle and display object. + // Create a node bundle, display and form display object. entity_create('node_type', array('type' => 'article'))->save(); entity_get_display('node', 'article', 'default')->save(); + entity_get_form_display('node', 'article', 'default')->save(); // Rename the article bundle and assert the entity display is renamed. $info = node_type_load('article'); @@ -217,14 +218,21 @@ public function testRenameDeleteBundle() { $info->save(); $old_display = entity_load('entity_display', 'node.article.default'); $this->assertFalse($old_display); + $old_form_display = entity_load('entity_form_display', 'node.article.default'); + $this->assertFalse($old_form_display); $new_display = entity_load('entity_display', 'node.article_rename.default'); $this->assertEqual('article_rename', $new_display->bundle); $this->assertEqual('node.article_rename.default', $new_display->id); + $new_form_display = entity_load('entity_form_display', 'node.article_rename.default'); + $this->assertEqual('article_rename', $new_form_display->bundle); + $this->assertEqual('node.article_rename.default', $new_form_display->id); // Delete the bundle. $info->delete(); $display = entity_load('entity_display', 'node.article_rename.default'); $this->assertFalse($display); + $form_display = entity_load('entity_form_display', 'node.article_rename.default'); + $this->assertFalse($form_display); } /**