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 @@ -42,6 +42,16 @@ protected $cacheBackend; /** + * Whether the static cache should be ignored when loading an entity. + * + * This property will be set by ::loadRevisionUnchanged() in order for + * ::loadRevision() to load the entity without using the static entity cache. + * + * @var bool + */ + protected $ignoreStaticCache; + + /** * Constructs a ContentEntityStorageBase object. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type @@ -849,7 +859,7 @@ } /** - * Resets the internal, static entity revision cache. + * Resets the static entity revision cache. * * @param $revision_ids * The revision cache will be reset for the entities with the given @@ -958,14 +968,12 @@ * The default revision id. */ protected function getDefaultRevisionId($id) { + $result = NULL; if ($this->entityType->isRevisionable()) { $result = $this->getQuery() ->condition($this->entityType->getKey('id'), $id) ->execute(); } - else { - $result = NULL; - } return $result ? key($result) : NULL; } diff -u b/core/lib/Drupal/Core/Entity/ContentEntityStorageInterface.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageInterface.php --- b/core/lib/Drupal/Core/Entity/ContentEntityStorageInterface.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageInterface.php @@ -21,7 +21,7 @@ /** * Load a specific entity revision. * - * @param int|string $revision_id + * @param int $revision_id * The revision id. * * @return \Drupal\Core\Entity\ContentEntityInterface|null @@ -32,7 +32,7 @@ /** * Loads an unchanged entity by revision id from the database. * - * @param mixed $revision_id + * @param int $revision_id * The revision ID of the entity to load. * * @return \Drupal\Core\Entity\ContentEntityInterface|null reverted: --- b/core/lib/Drupal/Core/Entity/EntityStorageBase.php +++ a/core/lib/Drupal/Core/Entity/EntityStorageBase.php @@ -14,7 +14,7 @@ * * @var array */ + protected $entities = array(); - protected $entities = []; /** * Entity type ID for this storage. diff -u b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueContentEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueContentEntityStorage.php --- b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueContentEntityStorage.php @@ -14,21 +14,24 @@ * {@inheritdoc} */ public function loadRevision($revision_id) { - // @todo + // @todo Complete the content entity storage implementation in + // https://www.drupal.org/node/2618436. } /** * {@inheritdoc} */ public function loadRevisionUnchanged($revision_id) { - // @todo + // @todo Complete the content entity storage implementation in + // https://www.drupal.org/node/2618436. } /** * {@inheritdoc} */ public function deleteRevision($revision_id) { - // @todo + // @todo Complete the content entity storage implementation in + // https://www.drupal.org/node/2618436. } /** reverted: --- b/core/modules/content_moderation/src/Entity/ContentModerationState.php +++ a/core/modules/content_moderation/src/Entity/ContentModerationState.php @@ -163,7 +163,6 @@ $related_entity = $related_entity->getTranslation($this->activeLangcode); } $related_entity->moderation_state = $this->moderation_state; - $this->entityTypeManager()->getStorage('content_moderation_state')->resetCache([$this->id()]); return $related_entity->save(); } reverted: --- b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php +++ a/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateTest.php @@ -264,7 +264,7 @@ $content_moderation_state->setNewRevision(TRUE); // Revision 7 (en, fr). $content_moderation_state->save(); + $english_node = $this->reloadEntity($french_node, $french_node->getRevisionId() + 1); - $english_node = $this->reloadEntity($french_node, 7); $this->assertEquals('draft', $english_node->moderation_state->value); $french_node = $this->reloadEntity($english_node)->getTranslation('fr'); diff -u b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php --- b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php +++ b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php @@ -8,6 +8,7 @@ namespace Drupal\Tests\migrate\Unit\destination; use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\ContentEntityStorageInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\migrate\destination\EntityRevision as RealEntityRevision; @@ -47,7 +48,7 @@ // Setup mocks to be used when creating a revision destination. $this->migration = $this->prophesize(MigrationInterface::class); - $this->storage = $this->prophesize('\Drupal\Core\Entity\ContentEntityStorageInterface'); + $this->storage = $this->prophesize(ContentEntityStorageInterface::class); $this->entityManager = $this->prophesize('\Drupal\Core\Entity\EntityManagerInterface'); $this->fieldTypeManager = $this->prophesize('\Drupal\Core\Field\FieldTypePluginManagerInterface'); } @@ -60,7 +61,7 @@ public function testGetEntityDestinationValues() { $destination = $this->getEntityRevisionDestination([]); // Return a dummy because we don't care what gets called. - $entity = $this->prophesize('\Drupal\Core\Entity\ContentEntityInterface') + $entity = $this->prophesize(ContentEntityInterface::class) ->willImplement('\Drupal\Core\Entity\RevisionableInterface'); // Assert that the first ID from the destination values is used to load the // entity.