From 26a6752fe23021e380bca7ba92eb2fa98c43bdb3 Mon Sep 17 00:00:00 2001
From: webchick <webchick@24967.no-reply.drupal.org>
Date: Wed, 5 Oct 2011 07:56:00 -0700
Subject: [PATCH] Issue #1079966 by dereine, catch: Fixed Notice when renaming
 bundles.

---
 modules/field_ui/field_ui.module | 11 +++++++++++
 modules/field_ui/field_ui.test   | 15 +++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/modules/field_ui/field_ui.module b/modules/field_ui/field_ui.module
index 6418ee82b3ac..90559cff22a8 100644
--- a/modules/field_ui/field_ui.module
+++ b/modules/field_ui/field_ui.module
@@ -47,6 +47,17 @@ function field_ui_help($path, $arg) {
   }
 }
 
+/**
+ * Implements hook_field_attach_rename_bundle().
+ */
+function field_ui_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
+  // The Field UI relies on entity_get_info() to build menu items for entity
+  // field administration pages. Clear the entity info cache and ensure that
+  // the menu is rebuilt.
+  entity_info_cache_clear();
+  menu_rebuild();
+}
+
 /**
  * Implements hook_menu().
  */
diff --git a/modules/field_ui/field_ui.test b/modules/field_ui/field_ui.test
index b852a6a6d037..e7c5e18e796b 100644
--- a/modules/field_ui/field_ui.test
+++ b/modules/field_ui/field_ui.test
@@ -411,6 +411,21 @@ class FieldUIManageFieldsTestCase extends FieldUITestCase {
     $this->drupalGet($bundle_path);
     $this->assertFalse($this->xpath('//select[@id="edit-add-existing-field-field-name"]//option[@value=:field_name]', array(':field_name' => $field_name)), t("The 'add existing field' select respects field types 'no_ui' property."));
   }
+
+  /**
+   * Tests renaming a bundle.
+   */
+  function testRenameBundle() {
+    $type2 = strtolower($this->randomName(8)) . '_' .'test';
+    $hyphen_type2 = str_replace('_', '-', $type2);
+
+    $options = array(
+      'type' => $type2,
+    );
+    $this->drupalPost('admin/structure/types/manage/' . $this->hyphen_type, $options, t('Save content type'));
+
+    $this->drupalGet('admin/structure/types/manage/' . $hyphen_type2 . '/fields');
+  }
 }
 
 /**
-- 
GitLab