diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php index dcde80d..61627b8 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php @@ -86,21 +86,13 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti */ public function preSave(EntityStorageInterface $storage) { // Only handle renames, not creations. - if ($this->getOriginalId() !== $this->id()) { + if (!$this->isNew() && $this->getOriginalId() !== $this->id()) { $bundle_type = $this->getEntityType(); $bundle_of = $bundle_type->getBundleOf(); if (!empty($bundle_of)) { - /* @var \Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface $entity_storage */ - $entity_storage = $this->entityManager()->getStorage($bundle_of); - assert('$entity_storage instanceof \Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface'); - if ($entity_storage->hasData()) { - throw new ConfigNameException(t("The machine name of this @bundle cannot be changed, because @content content already exists.", [ - '@bundle' => $bundle_type->getLabel(), - '@content' => $this->entityManager() - ->getDefinition($bundle_of) - ->getLabel(), - ])); - } + throw new ConfigNameException(t("The machine name of this @bundle cannot be changed.", [ + '@bundle' => $bundle_type->getLabel(), + ])); } } diff --git a/core/modules/node/src/Tests/NodeTypeTest.php b/core/modules/node/src/Tests/NodeTypeTest.php index 11d939a..c30b424 100644 --- a/core/modules/node/src/Tests/NodeTypeTest.php +++ b/core/modules/node/src/Tests/NodeTypeTest.php @@ -99,10 +99,9 @@ function testNodeTypeEditing() { $this->assertRaw('Foo', 'New title label was displayed.'); $this->assertNoRaw('Title', 'Old title label was not displayed.'); - // Change the name, machine name and description. + // Change the name and the description. $edit = array( 'name' => 'Bar', - 'type' => 'bar', 'description' => 'Lorem ipsum.', ); $this->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type')); @@ -111,16 +110,15 @@ function testNodeTypeEditing() { $this->assertRaw('Bar', 'New name was displayed.'); $this->assertRaw('Lorem ipsum', 'New description was displayed.'); $this->clickLink('Bar'); - $this->assertUrl(\Drupal::url('node.add', ['node_type' => 'bar'], ['absolute' => TRUE]), [], 'New machine name was used in URL.'); $this->assertRaw('Foo', 'Title field was found.'); $this->assertRaw('Body', 'Body field was found.'); // Remove the body field. - $this->drupalPostForm('admin/structure/types/manage/bar/fields/node.bar.body/delete', array(), t('Delete')); + $this->drupalPostForm('admin/structure/types/manage/page/fields/node.page.body/delete', array(), t('Delete')); // Resave the settings for this type. - $this->drupalPostForm('admin/structure/types/manage/bar', array(), t('Save content type')); + $this->drupalPostForm('admin/structure/types/manage/page', array(), t('Save content type')); // Check that the body field doesn't exist. - $this->drupalGet('node/add/bar'); + $this->drupalGet('node/add/page'); $this->assertNoRaw('Body', 'Body field was not found.'); } diff --git a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php index 1c174d4..a46a47e 100644 --- a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php @@ -143,37 +143,6 @@ function testTaxonomyVocabularyLoadMultiple() { } /** - * Tests that machine name changes are properly reflected. - */ - function testTaxonomyVocabularyChangeMachineName() { - // Add a field to the vocabulary. - entity_create('field_storage_config', array( - 'field_name' => 'field_test', - 'entity_type' => 'taxonomy_term', - 'type' => 'test_field', - ))->save(); - entity_create('field_config', array( - 'field_name' => 'field_test', - 'entity_type' => 'taxonomy_term', - 'bundle' => $this->vocabulary->id(), - ))->save(); - - // Change the machine name. - $old_name = $this->vocabulary->id(); - $new_name = Unicode::strtolower($this->randomMachineName()); - $this->vocabulary->set('vid', $new_name); - $this->vocabulary->save(); - - // Check that entity bundles are properly updated. - $info = entity_get_bundles('taxonomy_term'); - $this->assertFalse(isset($info[$old_name]), 'The old bundle name does not appear in entity_get_bundles().'); - $this->assertTrue(isset($info[$new_name]), 'The new bundle name appears in entity_get_bundles().'); - - // Check that the field is still attached to the vocabulary. - $this->assertTrue(FieldConfig::loadByName('taxonomy_term', $new_name, 'field_test'), 'The bundle name was updated correctly.'); - } - - /** * Test uninstall and reinstall of the taxonomy module. */ function testUninstallReinstall() {