only in patch2: unchanged: --- a/core/modules/content_moderation/src/Entity/ContentModerationState.php +++ b/core/modules/content_moderation/src/Entity/ContentModerationState.php @@ -158,7 +158,7 @@ public static function getCurrentUserId() { public function save() { $related_entity = \Drupal::entityTypeManager() ->getStorage($this->content_entity_type_id->value) - ->loadRevision($this->content_entity_revision_id->value); + ->loadRevisionUnchanged($this->content_entity_revision_id->value); if ($related_entity instanceof TranslatableInterface) { $related_entity = $related_entity->getTranslation($this->activeLangcode); } only in patch2: unchanged: --- a/core/modules/content_moderation/src/EntityOperations.php +++ b/core/modules/content_moderation/src/EntityOperations.php @@ -262,8 +262,11 @@ public function entityView(array &$build, EntityInterface $entity, EntityViewDis * TRUE if the default revision is published. FALSE otherwise. */ protected function isDefaultRevisionPublished(EntityInterface $entity, WorkflowInterface $workflow) { + // We have to load the unchanged entity for the default revision to ensure + // that we are not retrieving a modified entity from the static entity + // cache. $storage = $this->entityTypeManager->getStorage($entity->getEntityTypeId()); - $default_revision = $storage->load($entity->id()); + $default_revision = $storage->loadUnchanged($entity->id()); // Ensure we are comparing the same translation as the current entity. if ($default_revision instanceof TranslatableInterface && $default_revision->isTranslatable()) { only in patch2: unchanged: --- a/core/modules/content_moderation/src/ModerationInformation.php +++ b/core/modules/content_moderation/src/ModerationInformation.php @@ -74,7 +74,7 @@ public function shouldModerateEntitiesOfBundle(EntityTypeInterface $entity_type, */ public function getLatestRevision($entity_type_id, $entity_id) { if ($latest_revision_id = $this->getLatestRevisionId($entity_type_id, $entity_id)) { - return $this->entityTypeManager->getStorage($entity_type_id)->loadRevision($latest_revision_id); + return $this->entityTypeManager->getStorage($entity_type_id)->loadRevisionUnchanged($latest_revision_id); } } only in patch2: unchanged: --- a/core/modules/content_moderation/src/ModerationInformationInterface.php +++ b/core/modules/content_moderation/src/ModerationInformationInterface.php @@ -48,7 +48,7 @@ public function canModerateEntitiesOfEntityType(EntityTypeInterface $entity_type public function shouldModerateEntitiesOfBundle(EntityTypeInterface $entity_type, $bundle); /** - * Loads the latest revision of a specific entity. + * Loads the unmodified latest revision of a specific entity. * * @param string $entity_type_id * The entity type ID. only in patch2: unchanged: --- a/core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php +++ b/core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php @@ -69,7 +69,12 @@ protected function loadContentModerationStateRevision(ContentEntityInterface $en } /** @var \Drupal\content_moderation\ContentModerationStateInterface $content_moderation_state */ - $content_moderation_state = $content_moderation_storage->loadRevision(key($revisions)); + // In the case the content moderation state entity is edited and saved + // separately from the related entity it will trigger saving of the related + // entity and therefor the content moderation state will be loaded here + // again and we have to make sure we will load the unchanged entity and not + // load the already modified one from the static entity cache. + $content_moderation_state = $content_moderation_storage->loadRevisionUnchanged(key($revisions)); if ($entity->getEntityType()->hasKey('langcode')) { $langcode = $entity->language()->getId(); if (!$content_moderation_state->hasTranslation($langcode)) {