diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index 905a132..d995991 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -164,7 +164,7 @@ public function setValue($values, $notify = TRUE) { } elseif (isset($values['target_id']) && isset($values['entity'])) { // If both properties are passed, verify the passed values match. - if ($this->get('entity')->getTargetIdentifier() != $values['target_id']) { + if ($this->get('entity')->getTargetIdentifier() != $values['target_id'] && ($values['target_id'] != static::$NEW_ENTITY_MARKER || !$this->entity->isNew())) { throw new \InvalidArgumentException('The target id and entity passed to the entity reference item do not match.'); } } diff --git a/core/modules/language/src/Tests/EntityDefaultLanguageTest.php b/core/modules/language/src/Tests/EntityDefaultLanguageTest.php index fa1a759..b3b109a 100644 --- a/core/modules/language/src/Tests/EntityDefaultLanguageTest.php +++ b/core/modules/language/src/Tests/EntityDefaultLanguageTest.php @@ -31,6 +31,8 @@ class EntityDefaultLanguageTest extends KernelTestBase { public function setUp() { parent::setUp(); + $this->installEntitySchema('user'); + // Activate Spanish language, so there are two languages activated. $language = $this->container->get('entity.manager')->getStorage('configurable_language')->create(array( 'id' => 'es', diff --git a/core/modules/system/src/Tests/Entity/BundleConstraintValidatorTest.php b/core/modules/system/src/Tests/Entity/BundleConstraintValidatorTest.php index be2dc48..6886e29 100644 --- a/core/modules/system/src/Tests/Entity/BundleConstraintValidatorTest.php +++ b/core/modules/system/src/Tests/Entity/BundleConstraintValidatorTest.php @@ -29,6 +29,7 @@ class BundleConstraintValidatorTest extends KernelTestBase { protected function setUp() { parent::setUp(); + $this->installEntitySchema('user'); $this->typedData = $this->container->get('typed_data_manager'); } diff --git a/core/modules/system/src/Tests/Plugin/ContextPluginTest.php b/core/modules/system/src/Tests/Plugin/ContextPluginTest.php index c7dab96..5b04cd5 100644 --- a/core/modules/system/src/Tests/Plugin/ContextPluginTest.php +++ b/core/modules/system/src/Tests/Plugin/ContextPluginTest.php @@ -25,6 +25,8 @@ class ContextPluginTest extends KernelTestBase { * Tests basic context definition and value getters and setters. */ function testContext() { + $this->installEntitySchema('user'); + $name = $this->randomMachineName(); $manager = new MockBlockManager(); $plugin = $manager->createInstance('user_name');