Revisions log on translated nodes should not show original language revisions, should show revisions of translated content

Created on 5 November 2019, over 4 years ago
Updated 9 February 2024, 4 months ago

Problem/Motivation

Motivation:
Inconsistent behavior is confusing, and not seeing translation revisions hinders work of editors.

Problem:
Sometimes revisions tab on translated content only shows original source revisions.
This happens when the original source has a published version, before the translation has any published versions.

Proposed resolution

Show translation revisions on translation revisions tab.

Remaining tasks

  • Investigation into cause
  • Write test(s)

Steps to reproduce

Install Drupal 8.8+ with no contrib modules

Setup

  1. enable content translation (depends on language which will get enabled with it) /admin/modules
  2. enable workflows /admin/modules
  3. enable content moderation /admin/modules
  4. add a language (for example: spanish) /admin/config/regional/language
  5. configure content translation /admin/config/regional/content-language under "Custom language settings" check "Content" and then check the checkbox for Basic Page (leave the default fields checked) and save configuration
  6. configure workflows /admin/config/workflow/workflows/manage/editorial in the "This workflow applies to" section, next to "Content types", click "Select", check Basic Page, save, save

to see expected behavior

  1. add draft english content /node/add/page
    • notice /node/1 has tabs: View, Edit, Delete, Revisions, Translate
    • notice /node/1/revisions has one table row
  2. edit and keep in draft
    • notice /node/1 has tabs: View, Edit, Delete, Revisions, Translate
    • notice /node/1/revisions has two table rows
  3. translate node
    • notice /node/1 has tabs: View, Edit, Delete, Revisions, Translate
    • notice /node/1/revisions has two table row
    • notice /es/node/1/revisions has one table row

to see bug

  1. add draft english content /node/add/page
    • notice /node/1 has tabs: View, Edit, Delete, Revisions, Translate
    • notice /node/1/revisions has one table row
  2. edit and keep in draft
    • notice /node/1 has tabs: View, Edit, Delete, Revisions, Translate
    • notice /node/1/revisions has two table rows
  3. publish
    • notice /node/1 has tabs: View, Edit, Delete, Revisions, Translate
    • notice /node/1/revisions has three table rows
  4. translate node: *set state to draft* as saving translation, as creating the translation see https://www.drupal.org/files/issues/2019-11-05/creating-translation-in-d... β†’
    • notice on save goes to /es/node/2/latest
    • notice /es/node/2/latest has the translation
    • notice /es/node/2/latest has tabs: View, Edit, Latest version, Revisions, Translate
    • notice /es/node/2/revisions *unexpectedly* shows the english three revisions and no spanish revisions
    • notice /node/2/revisions (as expected) shows the english three revisions (and no spanish revisions)
  5. can edit the translation again, now, there are two revisions of the translation, but no way to see them via the Revisions tab

Bit more investigation

we can go back to the first case, and explore the as expected behavior a bit more, where neither is published, and publish the original language node

  1. edit first node, publish
  2. edit translation
    • notice the revisions for the translation show on the translation revision tab /es/node/1/revisions
    • notice the revisions for the original node show on the revisions tab /node/1/revisions

User interface changes

For the solution in #38: No changes

API changes

For the solution in #38: No changes

Data model changes

For the solution in #38: No changes

Release notes snippet

For the solution in #38: The node revisions page will now show the correct revisions for the translation even when the translation has never been published (ie draft only).

πŸ› Bug report
Status

Fixed

Version

10.2 ✨

Component
Content moderationΒ  β†’

Last updated 4 days ago

  • Maintained by
  • πŸ‡¦πŸ‡ΊAustralia @Sam152
Created by

πŸ‡ΊπŸ‡ΈUnited States YesCT

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • When I used the two patches at the same time, I merged them because the number of lines conflicted.(this page #17 and https://www.drupal.org/project/drupal/issues/3006897 πŸ› Impossible to delete published translations on unpublished nodes Needs work #17)

  • πŸ‡ΊπŸ‡ΈUnited States recrit

    @k9606 Please do not post "combo" patches in order to keep the issue focused on a single issue.. You should keep "combo" patches as a custom patch for your build.

  • πŸ‡ΊπŸ‡ΈUnited States recrit

    The attached patch simplifies the logic to check for this condition. The content_moderation's original checks already covered the majority of the added logic in patch #17. The attached patch #21 only adds a new condition to check when there is a non-default translation being saved as a non-default state with a published default revision. Example: en is published, es is draft.

    See my comments for the original patch below:

           $update_default_revision = $entity->isNew()
             || $current_state->isDefaultRevisionState()
    -        || !$this->moderationInfo->isDefaultRevisionPublished($entity);
    -
    +        || !$this->moderationInfo->isDefaultRevisionPublished($entity)
    +        || (
    #### COMMENT: If we got here in the logic, then  !$entity->isNew() will always be true.
    +          !$entity->isNew()
    #### COMMENT: This assumes $entity->original is the default translation. An easier check would be to check !$entity->isDefaultTranslation().
    +          // It means entity has been translated.
    +          && isset($entity->original)
    +          // it means you're saving translation entity.
    +          && $entity->original->language()->getId() != $entity->language()->getId()
    +          // It means no published revision.
    #### COMMENT: This assumes the permissions that are set for the site. If we got here in the logic, then the current state is not the default revision state, ie not published or any other state that should be the default revision.
    +          // Normally, anonymous users can see the public content.
    +          // Currently, Can not find a best way to do it.
    +          && !$entity->access('view', User::load(0))
    +        );
    

    New patch #21:

           $update_default_revision = $entity->isNew()
             || $current_state->isDefaultRevisionState()
    -        || !$this->moderationInfo->isDefaultRevisionPublished($entity);
    +        || !$this->moderationInfo->isDefaultRevisionPublished($entity)
    +        || ($entity instanceof TranslatableInterface && !$entity->isDefaultTranslation());
    
  • πŸ‡ΊπŸ‡ΈUnited States recrit

    Some more reasons on why this is a bad bug:
    When in this state of PUBLISHED default translation (example English) with a new DRAFT only translation (example Spanish), the following occur:
    - Revision logs are incorrect as stated in this issue's original report.
    - Any check for $entity->hasTranslation(es) return FALSE, and consequently and loading of the translation with $entity->getTranslation(es)
    - The Spanish DRAFT will not display in the admin content list at "/admin/content" since there is no record for the Spanish translation in the node_field_data database table which the admin content view uses.

  • Status changed to Needs review about 1 year ago
  • last update about 1 year ago
    30,230 pass, 10 fail
  • πŸ‡ΊπŸ‡ΈUnited States recrit
  • last update about 1 year ago
    30,298 pass, 5 fail
  • πŸ‡ΊπŸ‡ΈUnited States recrit

    The patch #21 and #17 did not support the translation having a published revision and a draft revision. Those patches would always set the draft as the default revision resulting in no published revision.
    The patch attached supports translations having a published revision and a draft revision.

  • last update about 1 year ago
    30,303 pass, 5 fail
  • πŸ‡ΊπŸ‡ΈUnited States recrit

    Updated the failing tests with the new expectations for a default revision being created for a draft translation.

  • Status changed to Needs work about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States recrit
  • πŸ‡ΊπŸ‡ΈUnited States recrit

    The previous patches #27 and earlier have an issue where you could create a fork of the revisions ultimately resulting in data loss when you have the following:
    - Source translationL (ie English): Published and a Draft.
    - Translation (ie Spanish): Created initially as a Draft when the source has a draft. Then publish the translation before the Source translation's draft is published.

    For this reason, I suggest that we focus this ticket on fixing the node revision overview page only.

    Related Issues:
    - #2860097: Ensure that content translations can be moderated independently β†’
    - #2766957: Forward revisions + translation UI can result in forked draft revisions β†’

  • πŸ‡ΊπŸ‡ΈUnited States recrit

    The attached patch alters any "entity.{entity type}.version_history" routes to load the latest version. This will show the correct revisions when there is only a draft version of a translation.

  • Status changed to Needs review about 1 year ago
  • last update about 1 year ago
    Custom Commands Failed
  • πŸ‡ΊπŸ‡ΈUnited States recrit
  • Status changed to Needs work about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    I don't see the proposed solution in the IS, that will need to be added.

    Also as a bug will need a test case showing the bug

    Thanks.

  • Status changed to Needs review about 1 year ago
  • last update about 1 year ago
    30,329 pass, 2 fail
  • πŸ‡ΊπŸ‡ΈUnited States recrit

    code cleanup, test still pending.

  • Status changed to Needs work about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thanks for updating the patch but not ready for review yet for the points in #33.

    If you're trying to see if the tests pass you can still upload a patch and click "Add test / reset" underneath to run the tests without putting into review.

  • πŸ‡ΊπŸ‡ΈUnited States recrit

    The root cause for this display issue of the revision overview page is that the NodeController::revisionOverview() depends on the routed node object / $node function argument for the following:
    1. To determine if the node has translations.
    2. Assumes that the $node argument is the default node revision.

    Proposed Resolution:
    Update the NodeController::revisionOverview() to be independent of the $node argument.

    Reasoning::
    1. The root cause of this display issue is in NodeController::revisionOverview().
    2. The entity.node.version_history route is the only "version_history" route so checking for the route and altering it in Drupal\content_moderation\Routing\ContentModerationRouteSubscriber no longer made sense. Previous patches #31 and #34 altered the entity.node.version_history route.
    3. By updating NodeController::revisionOverview() only and not updating entity.node.version_history in node.routing.yml with "load_latest_revision", this supports any custom class that exends the NodeController. The custom class would not need to know the semantics that the $node argument must be the latest revision.

    Other related issues:
    This resolution only fixes the display issue of the node revisions when the source node is published and there is a draft only revision of a translation.
    In this scenario, there will not be an entry for the translation in the node_field_data table which can cause the other issues belwo:
    1. Any check for $entity->hasTranslation(es) with the default revision of the source language will return FALSE, and consequently and loading of the translation with $entity->getTranslation(es)
    2. The translation DRAFT will not display in an admin content list view that is based on the node_field_data table since there is no record for the translation in that database table.
    3. A moderated views view based on the node_field_revision table will display all translation revisions information correctly; however, it will not display information from the base node_field_data table for a draft only translation. Example "Content Type" cannot be displayed. The base data is joined with node_field_revision.nid = node_field_data_node_field_revision.nid AND node_field_data_node_field_revision.langcode = node_field_revision.langcode. Since it joins langauge, there will never be a match.

  • last update about 1 year ago
    30,330 pass
  • πŸ‡ΊπŸ‡ΈUnited States recrit

    Pending:
    - patch updated with new tests, most likely added to content_moderation module since it sets the default revision flag.
    - new-tests-only patch to show core fails without the new patch

  • πŸ‡ΊπŸ‡ΈUnited States recrit

    Patches attached:
    1. 3092558-38--with-tests.patch: Update from #36 with new tests. This should PASS the automated tests.
    2. 3092558-38--tests-only.patch: Only the new tests. This should FAIL the automated tests.

  • last update about 1 year ago
    30,331 pass
  • last update about 1 year ago
    30,327 pass, 2 fail
  • Status changed to Needs review about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States recrit
  • last update about 1 year ago
    29,403 pass
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Cleaning up tags some.

  • Status changed to Needs work 12 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Asked catch in #needs-review-queue-initative channel and this doesn't need submaintainer review actually.

    But still think the issue summary could be updated. Seems to reference 8.8 are thinks the same for D10?

    Unknown used in a few spots doesn't seem right.

  • πŸ‡ΊπŸ‡ΈUnited States recrit

    updated he issue summary with the approach in "3092558-38--with-tests.patch"

  • Status changed to Needs review 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States recrit
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Issue summary appears to have been updated.

    Haven't tested but does this bug affect other entities using revisions?

  • Status changed to Needs work 9 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Status changed to Needs review 9 months ago
  • Open on Drupal.org β†’
    Environment: PHP 8.2 & MySQL 8
    last update 9 months ago
    Waiting for branch to pass
  • πŸ‡ΊπŸ‡ΈUnited States recrit

    Re-roll of #38 against 11.x and removed the forbidden word "please".

  • πŸ‡ΊπŸ‡ΈUnited States recrit

    @smustgrave I have not looked into the new generic entity revision controller that can be used by any entity type. I suspect that it could have this same issue with translations since loading the default translation revision is the same for any type.

  • Status changed to Needs work 8 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Status changed to Needs review 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States recrit

    re-rolled for the latest 11.x changes

  • last update 8 months ago
    30,484 pass
  • πŸ‡ΊπŸ‡ΈUnited States recrit

    Adding a D10.1.x patch.

  • last update 8 months ago
    29,679 pass
  • Status changed to Needs work 7 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • @recrit opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States recrit

    Created the following MRs:
    - 11.x: MR 5439 based on 3092558-48--D11.patch
    - 10.1.x: MR 5440 based on 3092558-49--D10.1.patch

  • Status changed to Needs review 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States recrit
  • Status changed to Needs work 7 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • πŸ‡ΊπŸ‡ΈUnited States recrit

    no clue what the review bot wants here. Both MR's are passing.

  • Status changed to Needs review 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States recrit
  • Status changed to Needs work 7 months ago
  • The Needs Review Queue Bot β†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • Status changed to Needs review 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States recrit

    rebased the 11.x MR 5439 since 1 hour after the branch was created it is no longer mergeable...

  • Status changed to RTBC 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Rebased earlier for the test-only job and forgot to post

    There was 1 error:
    1) Drupal\Tests\content_moderation\Functional\ModerationLocaleTest::testTranslationRevisionsHistory
    Behat\Mink\Exception\ResponseTextException: The text "Log Message - French - Draft - Edit 1" was not found anywhere in the text of the current page.
    /builds/issue/drupal-3092558/vendor/behat/mink/src/WebAssert.php:811
    /builds/issue/drupal-3092558/vendor/behat/mink/src/WebAssert.php:262
    /builds/issue/drupal-3092558/core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php:491
    /builds/issue/drupal-3092558/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
    ERRORS!
    

    Was difficult to replicate but believe I'm seeing the issue and change doesn't seem unreasonable.

    • catch β†’ committed 12ef050d on 10.2.x
      Issue #3092558 by recrit, vijaycs85, smustgrave, aloneblood, k9606,...
    • catch β†’ committed 2feaa299 on 11.x
      Issue #3092558 by recrit, vijaycs85, smustgrave, aloneblood, k9606,...
  • Status changed to Fixed 5 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    This is tricky and I'm not even sure I agree with the concept of not showing revisions for other languages on the revisions tab - but that decision wasn't introduced here so we should make it work how it's currently designed.

    Committed/pushed to 11.x and cherry-picked to 10.2.x, thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024