diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php index b017e9b..70096a0 100644 --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php @@ -186,7 +186,7 @@ protected function ensureTableExists() { /** * Defines the schema for the configuration table. */ - public static function schemaDefinition() { + protected static function schemaDefinition() { $schema = array( 'description' => 'The base table for configuration data.', 'fields' => array( diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 6627b3d..2580ae4 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -328,12 +328,14 @@ public function preSave(EntityStorageInterface $storage) { // Ensure this entity's UUID does not exist with a different ID, regardless // of whether it's new or updated. - $matching_entities = $storage->getQuery() - ->condition('uuid', $this->uuid()) - ->execute(); - $matched_entity = reset($matching_entities); - if (!empty($matched_entity) && ($matched_entity != $this->id()) && $matched_entity != $this->getOriginalId()) { - throw new ConfigDuplicateUUIDException("Attempt to save a configuration entity '{$this->id()}' with UUID '{$this->uuid()}' when this UUID is already used for '$matched_entity'"); + if ($uuid = $this->uuid()) { + $matching_entities = $storage->getQuery() + ->condition('uuid', $this->uuid()) + ->execute(); + $matched_entity = reset($matching_entities); + if (!empty($matched_entity) && ($matched_entity != $this->id()) && $matched_entity != $this->getOriginalId()) { + throw new ConfigDuplicateUUIDException("Attempt to save a configuration entity '{$this->id()}' with UUID '{$this->uuid()}' when this UUID is already used for '$matched_entity'"); + } } // If this entity is not new, load the original entity for comparison. diff --git a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php index 3d2575b..3a19370 100644 --- a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php +++ b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php @@ -178,7 +178,7 @@ public function setIfNotExists($key, $value) { } // Now that the bin has been created, try again if necessary. if ($try_again) { - $this->setIfNotExists($key, $value); + return $this->setIfNotExists($key, $value); } } @@ -273,7 +273,7 @@ protected function catchException(\Exception $e) { /** * Defines the schema for the batch table. */ - public static function schemaDefinition() { + public function schemaDefinition() { return [ 'description' => 'Generic key-value storage table. See the state system for an example.', 'fields' => [ diff --git a/core/modules/system/src/Tests/Entity/FieldWidgetConstraintValidatorTest.php b/core/modules/system/src/Tests/Entity/FieldWidgetConstraintValidatorTest.php index 4f223e3..f9dec1f 100644 --- a/core/modules/system/src/Tests/Entity/FieldWidgetConstraintValidatorTest.php +++ b/core/modules/system/src/Tests/Entity/FieldWidgetConstraintValidatorTest.php @@ -29,7 +29,7 @@ class FieldWidgetConstraintValidatorTest extends KernelTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', ['router', 'key_value']); + $this->installSchema('system', ['router']); $this->container->get('router.builder')->rebuild(); $this->installEntitySchema('user');