diff --git a/core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php b/core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php index 8c769cbdf6..cbeb51a062 100644 --- a/core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php +++ b/core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php @@ -30,6 +30,19 @@ protected function computeValue() { } /** + * Ensures that values are only computed once. + */ + protected function ensureComputedValue() { + // If the moderation state field is set to an empty value, always recompute + // the state. Empty is not a valid moderation state value, when none is + // preset the default state is used. + if ($this->valueComputed === FALSE || $this->list[0]->isEmpty()) { + $this->computeValue(); + $this->valueComputed = TRUE; + } + } + + /** * Gets the moderation state ID linked to a content entity revision. * * @return string|null