diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php index 3fb8c41..b82017a 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php @@ -431,9 +431,9 @@ protected function doPreSave(EntityInterface $entity) { } // Load the previous revision, if any. - if (isset($entity->original_revision) && !isset($entity->previous)) { - $entity->previous = $this->loadRevision($entity->original_revision); - unset($entity->original_revision); + if (isset($entity->previous_revision) && !isset($entity->previous)) { + $entity->previous = $this->loadRevision($entity->previous_revision); + unset($entity->previous_revision); } // Allow code to run before saving. diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 46ddd90..54a3659 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -402,7 +402,9 @@ function entity_test_entity_test_insert($entity) { * Implements hook_entity_update(). */ function entity_test_entity_update(EntityInterface $entity) { - \Drupal::state()->set('entity_test.previous', $entity->previous); + if (isset($entity->previous)) { + \Drupal::state()->set('entity_test.previous', $entity->previous); + } } /** diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityPreviousPropertyTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityPreviousPropertyTest.php index d9f6632..525bb6c 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityPreviousPropertyTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityPreviousPropertyTest.php @@ -40,10 +40,5 @@ public function testPreviousProperty() { $previous = \Drupal::state()->get('entity_test.previous'); $this->assertEquals($entity->getRevisionId(), $previous->getRevisionId()); $this->assertNotEquals($loaded->getRevisionId(), $previous->getRevisionId()); - - $loaded->set('name', 'dublin'); - $loaded->save(); - $previous2 = \Drupal::state()->get('entity_test.previous'); - $this->assertEquals($loaded->getRevisionId(), $previous2->getRevisionId()); } }