From d625f2c3e92c0f84e323b6472918c1f5bcb9b3ac Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Sun, 30 Jun 2013 12:47:30 +0100 Subject: [PATCH] Issue #2030465 by swentel: Clean up entity form displays when deleting a bundle. --- core/modules/entity/entity.module | 4 ++-- .../lib/Drupal/entity/Tests/EntityDisplayTest.php | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index 7a9c8a84e1..ad9d17b140 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 4337abdc32..6a0ddc55d9 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); } /** -- GitLab