diff -u b/core/lib/Drupal/Core/Config/CreationHash.php b/core/lib/Drupal/Core/Config/CreationHash.php --- b/core/lib/Drupal/Core/Config/CreationHash.php +++ b/core/lib/Drupal/Core/Config/CreationHash.php @@ -62,7 +62,10 @@ * {@inheritdoc} */ public function generate($id) { - return $this->getPrefix() . '__' . $id; + // We need to replace dots in the ids since the uuid is being used in field + // and table names. Without this \Drupal\field\Tests\FieldImportDeleteTest + // does not pass. + return $this->getPrefix() . '__' . str_replace('.', '__', $id); } } diff -u b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php --- b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -332,12 +332,7 @@ // whether a configuration entity with the same ID (if any) already exists. $entity->enforceIsNew(); - // Assign a new UUID if there is none yet. - if (!isset($entity->{$this->uuidKey})) { - $entity->{$this->uuidKey} = $this->creationHash->generate($entity->id()); - } $entity->postCreate($this); - // Modules might need to add or change the data initially held by the new // entity object, for instance to fill-in default values. $this->invokeHook('create', $entity); @@ -347,6 +342,11 @@ $entity->{$this->statusKey} = TRUE; } + // Assign a new UUID if there is none yet. + if (!isset($entity->{$this->uuidKey})) { + $entity->{$this->uuidKey} = $this->creationHash->generate($entity->id()); + } + return $entity; } diff -u b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php --- b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php @@ -122,16 +122,16 @@ /** * {@inheritdoc} */ - public static function preCreate(EntityStorageControllerInterface $storage_controller, array &$values) { + public function postCreate(EntityStorageControllerInterface $storage_controller) { // Build an id if none is set. Since a particular name can be used by // multiple theme/modules we need to make a unique id. - if (empty($values['id'])) { - $values['id'] = $values['sourceType'] . '.' . $values['source'] . '.' . $values['name']; + if (empty($this->id)) { + $this->id = $this->sourceType . '.' . $this->source . '.' . $this->name; } // Set the label if none is set. - if (empty($values['label'])) { - $values['label'] = $values['name']; + if (empty($this->label)) { + $this->label = $this->name; } } diff -u b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php --- b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php @@ -104,9 +104,9 @@ /** * {@inheritdoc} */ - public static function preCreate(EntityStorageControllerInterface $storage_controller, array &$values) { - if (empty($values['id'])) { - $values['id'] = $values['sourceType'] . '.' . $values['source'] . '.' . $values['name']; + public function postCreate(EntityStorageControllerInterface $storage_controller) { + if (empty($this->id)) { + $this->id = $this->sourceType . '.' . $this->source . '.' . $this->name; } } diff -u b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallWebTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallWebTest.php --- b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallWebTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallWebTest.php @@ -98,7 +98,7 @@ drupal_flush_all_caches(); $default_config_entity = entity_load('config_test', 'dotted.default'); $default_config_entity_creation_hash = $default_config_entity->uuid(); - $this->assertEqual($default_config_entity_creation_hash, 'ModuleHandler::install__dotted.default'); + $this->assertEqual($default_config_entity_creation_hash, 'ModuleHandler::install__dotted__default'); $edit = array( 'id' => 'test_creation_hash', @@ -107,7 +107,7 @@ $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save'); $custom_config_entity = entity_load('config_test', 'test_creation_hash'); $custom_config_entity_creation_hash = $custom_config_entity->uuid(); - $this->assertFalse(strpos($custom_config_entity_creation_hash, 'ModuleHandler::install'), "Runtime generated configuration creation hash does not contain ModuleHandler::install"); + $this->assertIdentical(FALSE, strpos($custom_config_entity_creation_hash, 'ModuleHandler::install'), "Runtime generated configuration creation hash does not contain ModuleHandler::install"); \Drupal::moduleHandler()->uninstall(array('config_test')); diff -u b/core/tests/Drupal/Tests/Core/Config/CreationHashTest.php b/core/tests/Drupal/Tests/Core/Config/CreationHashTest.php --- b/core/tests/Drupal/Tests/Core/Config/CreationHashTest.php +++ b/core/tests/Drupal/Tests/Core/Config/CreationHashTest.php @@ -27,7 +27,7 @@ ->will($this->returnValue('generated-uuid')); $creationHash = new CreationHash($uuid); - $this->assertEquals('generated-uuid__test.id', $creationHash->generate('test.id')); + $this->assertEquals('generated-uuid__test__id', $creationHash->generate('test.id')); } public function testCreationHashPrefix() { @@ -38,12 +38,12 @@ $creationHash = new CreationHash($uuid); $creationHash->setPrefix('CreationHashTest'); - $this->assertEquals('CreationHashTest__test.id', $creationHash->generate('test.id')); + $this->assertEquals('CreationHashTest__test__id', $creationHash->generate('test.id')); // Ensure that the prefix cannot be reset. This allows themes to be enabled // by profiles in their hook_install implementation. $creationHash->setPrefix('AnotherPrefix'); - $this->assertEquals('CreationHashTest__test.id', $creationHash->generate('test.id')); + $this->assertEquals('CreationHashTest__test__id', $creationHash->generate('test.id')); } } only in patch2: unchanged: --- a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php @@ -31,7 +31,7 @@ public static function getInfo() { public function testConfigName() { // Try an invalid sourceType. $breakpoint = entity_create('breakpoint', array( - 'label' => drupal_strtolower($this->randomName()), + 'name' => drupal_strtolower($this->randomName()), 'source' => 'custom_module', 'sourceType' => 'oops', )); @@ -74,8 +74,9 @@ public function testConfigName() { $this->assertTrue($exception, 'breakpoint_config_name: An exception is thrown when an invalid name is entered.'); // Try a valid breakpoint. - $breakpoint->id = ''; - $breakpoint->name = drupal_strtolower($this->randomName()); + $breakpoint = entity_create('breakpoint', array( + 'name' => drupal_strtolower($this->randomName()), + )); $breakpoint->mediaQuery = 'all'; $exception = FALSE; @@ -83,9 +84,10 @@ public function testConfigName() { $breakpoint->save(); } catch (\Exception $e) { + $this->fail($e->getMessage()); $exception = TRUE; } $this->assertFalse($exception, 'breakpoint_config_name: No exception is thrown when a valid breakpoint is passed.'); - $this->assertEqual($breakpoint->id(), Breakpoint::SOURCE_TYPE_USER_DEFINED . '.custom_module.' . $breakpoint->name, 'breakpoint_config_name: A id is set when a valid breakpoint is passed.'); + $this->assertEqual($breakpoint->id(), Breakpoint::SOURCE_TYPE_USER_DEFINED . '.user.' . $breakpoint->name, 'breakpoint_config_name: A id is set when a valid breakpoint is passed.'); } } only in patch2: unchanged: --- a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php @@ -28,7 +28,7 @@ public static function getInfo() { public function testBreakpointCRUD() { // Add a breakpoint with minimum data only. $breakpoint = entity_create('breakpoint', array( - 'label' => drupal_strtolower($this->randomName()), + 'name' => drupal_strtolower($this->randomName()), 'mediaQuery' => '(min-width: 600px)', )); $breakpoint->save();