diff --git a/core/modules/content_moderation/src/ModerationInformation.php b/core/modules/content_moderation/src/ModerationInformation.php index 58eaa9f..e8bb186 100644 --- a/core/modules/content_moderation/src/ModerationInformation.php +++ b/core/modules/content_moderation/src/ModerationInformation.php @@ -171,13 +171,13 @@ public function isDefaultRevisionPublished(ContentEntityInterface $entity) { // Load the translated revision. $language_revision = $default_revision->getTranslation($language->getId()); // Return TRUE if a translation with a published state is found. - if ($workflow->getTypePlugin()->getState($language_revision->moderation_state->value)->isPublishedState()) { + if ($language_revision->moderation_state->value && $workflow->getState($language_revision->moderation_state->value)->isPublishedState()) { return TRUE; } } } - return $workflow->getTypePlugin()->getState($default_revision->moderation_state->value)->isPublishedState(); + return $default_revision->moderation_state->value && $workflow->getState($default_revision->moderation_state->value)->isPublishedState(); } /** diff --git a/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php b/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php index bfbdac5..8d6d54b 100644 --- a/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php +++ b/core/modules/content_moderation/src/Plugin/Validation/Constraint/ModerationStateConstraintValidator.php @@ -7,6 +7,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\content_moderation\ModerationInformationInterface; use Drupal\content_moderation\StateTransitionValidation; +use Drupal\Core\TypedData\TranslatableInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; @@ -131,11 +132,19 @@ public function validate($value, Constraint $constraint) { protected function isFirstTimeModeration(EntityInterface $entity) { $original_entity = $this->moderationInformation->getLatestRevision($entity->getEntityTypeId(), $entity->id()); + if ($original_entity instanceof TranslatableInterface && $original_entity->isTranslatable()) { + $language = $entity->language(); + // Use Language specific revision for translatable content. + if ($original_entity->hasTranslation($language->getId())) { + $original_entity = $original_entity->getTranslation($language->getId()); + } + } + if ($original_entity) { - $original_id = $original_entity->moderation_state; + $original_id = $original_entity->moderation_state->value; } - return !($entity->moderation_state && $original_entity && $original_id); + return !($entity->moderation_state->value && $original_entity && $original_id); } }