- fathima.asmat London, UK
Patch 6 works for new translations but does not affect existing draft translation that should be treated as default revision when there isn't a published translation. So we may need something like:
// Check if any of the translation revision has a published version, // otherwise set the latest translation to default revision. if (!$update_default_revision && $entity instanceof TranslatableInterface && $entity instanceof RevisionableInterface) { $update_default_revision = $entity->isNewTranslation(); if (!$update_default_revision) { $update_default_translation_revision = FALSE; $published_translation_revision = FALSE; $langcode = $this->languageManager->getCurrentLanguage()->getId(); $storage = $this->entityTypeManager ->getStorage($entity->getEntityTypeId()); $revision_ids = $storage->revisionIds($entity); if ($revision_ids) { foreach ($revision_ids as $revision_id) { $revision = $storage->loadRevision($revision_id); if ($revision->hasTranslation($langcode) && ($translation = $revision->getTranslation($langcode)) && $translation->isRevisionTranslationAffected()) { if ($workflow->getTypePlugin() ->getState($translation->moderation_state->value) ->isPublishedState()) { $published_translation_revision = TRUE; break; } } } } if (!$published_translation_revision && $entity->hasTranslation($langcode) && $translation = $entity->getTranslation($langcode)) { $update_default_translation_revision = !($workflow->getTypePlugin() ->getState($translation->moderation_state->value) ->isPublishedState()); } $update_default_revision = $update_default_translation_revision; } }
Patch attached.
- Status changed to Needs review
over 1 year ago 2:18pm 23 February 2023 The last submitted patch, 31: content-moderation-unpublished-translation-3088790-31.patch, failed testing. View results β
- Status changed to Needs work
over 1 year ago 1:53am 2 May 2023 - πΊπΈUnited States dabblela
Agreed with @fathima.asmat, this definitely needs a way to update the default revision of a translation that has never been published. I think it can be done with this code, but I'm a little wary of potentially looping through every revision of a node so I took a different approach.
I was able to fix the issue here by:
1) applying the patch from π New translations for moderated nodes are not created in the initial workflow state Needs work
2) setting the default moderation state to "Default moderation state" and
3) creating a new state called "Pre-published" with "Default revision" enabledThis approach has worked better in testing with modules that use `hasTranslationChanges` (eg, paragraphs), I think because the default revision field is set earlier in the entity save process.
- ππΊHungary mibfire
https://www.drupal.org/project/drupal/issues/3088790#comment-14937914 π Inconsistent database because of a bug in the Content Moderation module Needs work
This patch doesn't work in the following case:
- Content moderation with https://www.drupal.org/files/issues/2023-02-23/content-moderation-unpubl... β and moderation/translation enabled on a content type.
- Enable Croatian language.
- Create a Draft node in Croatian.
- Translate this node to English(Draft).
- Submit the Croatian translation into Published state.
- Submit the Croatian translation into Unpublished state.
- Check the node view page of Croatian translation where the "Latest version" tab should be visible(but it is not because the default revision is always the last revision).
However this scenario works with https://www.drupal.org/files/issues/2020-06-09/3088790-10.patch β and https://www.drupal.org/project/drupal/issues/3329066#comment-14962117 π Creating a new translation may delete translations with drafts Fixed patches. Plus this works with https://www.drupal.org/project/drupal/issues/3088790#comment-14839675 π Inconsistent database because of a bug in the Content Moderation module Needs work too.
- πΊπ¦Ukraine v.dovhaliuk
A new patch resolves an issue if Content Moderation is enabled for the Taxonomy, and
$revision_ids = $storage->revisionIds($entity);
throws an errorundefined method <code>revisionIds()