diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 5a4073f..dd4bc8e 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -156,8 +156,8 @@ public function label() { * {@inheritdoc} */ public function urlInfo($rel = 'canonical', array $options = []) { - if ($this->isNew()) { - throw new EntityMalformedException(sprintf('The "%s" entity type has not been saved, and cannot have a URI.', $this->getEntityTypeId())); + if ($this->id() === NULL) { + throw new EntityMalformedException(sprintf('The "%s" entity cannot have a URI as it does have an ID', $this->getEntityTypeId())); } // The links array might contain URI templates set in annotations. diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index f7bb02b..228825f 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -988,7 +988,6 @@ protected function doSave($id, EntityInterface $entity) { if ($this->revisionDataTable) { $this->saveToSharedTables($entity, $this->revisionDataTable); } - $entity->enforceIsNew(FALSE); } $this->invokeFieldMethod($is_new ? 'insert' : 'update', $entity); $this->saveToDedicatedTables($entity, !$is_new); @@ -996,6 +995,7 @@ protected function doSave($id, EntityInterface $entity) { if (!$is_new && $this->dataTable) { $this->invokeTranslationHooks($entity); } + $entity->enforceIsNew(FALSE); if ($this->revisionTable) { $entity->setNewRevision(FALSE); }