diff -u b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php --- b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -238,7 +238,7 @@ // having to load the entity object from the storage, then check if there // is already an entry in the static entity revisions cache for it and if // not load the entity from the storage. - if ($this->entityType->isStaticallyCacheable() && $this->entityType->isRevisionable()) { + if ($entity && $this->entityType->isStaticallyCacheable() && $this->entityType->isRevisionable()) { // If the default revision is not present in the static entity revision // cache we add it and return the entity. if (!$this->getFromStaticEntityRevisionCache($entity->getRevisionId())) { @@ -260,10 +260,11 @@ $this->setStaticEntityRevisionCache($revision_id, $revision); } else { - $revision = $this->doLoadRevision($revision_id); - $this->setStaticEntityRevisionCache($revision_id, $revision); - if ($revision->isDefaultRevision()) { - $this->setPersistentCache([$revision->id() => $revision]); + if ($revision = $this->doLoadRevision($revision_id)) { + $this->setStaticEntityRevisionCache($revision_id, $revision); + if ($revision->isDefaultRevision()) { + $this->setPersistentCache([$revision->id() => $revision]); + } } } } @@ -692,8 +693,8 @@ ); foreach ($entities as $id => $entity) { $this->cacheBackend->set($this->buildCacheId($id), $entity, CacheBackendInterface::CACHE_PERMANENT, $cache_tags); - if ($revision_id = $entity->getRevisionId()) { - $this->cacheBackend->set($this->buildRevisionCacheId($revision_id), $entity, CacheBackendInterface::CACHE_PERMANENT, $cache_tags); + if ($this->entityType->isRevisionable()) { + $this->cacheBackend->set($this->buildRevisionCacheId($entity->getRevisionId()), $entity, CacheBackendInterface::CACHE_PERMANENT, $cache_tags); } } } only in patch2: unchanged: --- a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php +++ b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php @@ -46,7 +46,7 @@ public function setUp() { // Setup mocks to be used when creating a revision destination. $this->migration = $this->prophesize('\Drupal\migrate\Entity\MigrationInterface'); - $this->storage = $this->prophesize('\Drupal\Core\Entity\EntityStorageInterface'); + $this->storage = $this->prophesize('\Drupal\Core\Entity\ContentEntityStorageInterface'); $this->entityManager = $this->prophesize('\Drupal\Core\Entity\EntityManagerInterface'); $this->fieldTypeManager = $this->prophesize('\Drupal\Core\Field\FieldTypePluginManagerInterface'); } @@ -59,7 +59,7 @@ public function setUp() { public function testGetEntityDestinationValues() { $destination = $this->getEntityRevisionDestination([]); // Return a dummy because we don't care what gets called. - $entity = $this->prophesize('\Drupal\Core\Entity\EntityInterface') + $entity = $this->prophesize('\Drupal\Core\Entity\ContentEntityInterface') ->willImplement('\Drupal\Core\Entity\RevisionableInterface'); // Assert that the first ID from the destination values is used to load the // entity. only in patch2: unchanged: --- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php @@ -833,23 +833,6 @@ public function testLoadMultipleIds() { } /** - * @covers ::loadRevision - */ - public function testLoadRevision() { - $this->assertSame(NULL, $this->entityStorage->loadRevision(1)); - } - - /** - * @covers ::deleteRevision - */ - public function testDeleteRevision() { - $this->cacheTagsInvalidator->expects($this->never()) - ->method('invalidateTags'); - - $this->assertSame(NULL, $this->entityStorage->deleteRevision(1)); - } - - /** * @covers ::delete * @covers ::doDelete */ only in patch2: unchanged: --- a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php @@ -596,24 +596,6 @@ public function testLoadMultipleIds() { } /** - * @covers ::loadRevision - */ - public function testLoadRevision() { - $this->setUpKeyValueEntityStorage(); - - $this->assertSame(NULL, $this->entityStorage->loadRevision(1)); - } - - /** - * @covers ::deleteRevision - */ - public function testDeleteRevision() { - $this->setUpKeyValueEntityStorage(); - - $this->assertSame(NULL, $this->entityStorage->deleteRevision(1)); - } - - /** * @covers ::delete * @covers ::doDelete */