Problem/Motivation

After I change source language of a node (basically, any translatable and revisionable entity), revision history is lost.

Steps to reproduce:

- Install "Content translation" module
- Add language other than English (i.e. French)
- In "Basic page" content type settings, enable the following:
-- Create new revision by default
-- Enable translation
-- Show language selector on create and edit pages
- Create new basic page in English
- Change title/body, write something in "Revision log message", save
- Go to edit of the same page, change language to "French", write something in "Revision log message", save
- Go to "Revisions" tab

Expected result: see all node revisions

Actual result: only the last revision is shown

Why this happens:

In NodeController::revisionOverview():

<?php
    foreach ($this->getRevisionIds($node, $node_storage) as $vid) {
      /** @var \Drupal\node\NodeInterface $revision */
      $revision = $node_storage->loadRevision($vid);
      // Only show revisions that are affected by the language that is being
      // displayed.
      if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
?>

The second check ($revision->getTranslation($langcode)->isRevisionTranslationAffected()) fails, because change of the source language
does not set revision_translation_affected flag. So - all revisions except the last one are skipped in the loop.

Proposed resolution

Always set revision_translation_affected flag when changing default node language.

Remaining tasks

- Write the patch
- Add test

User interface changes

No UI change

API changes

No API change

Data model changes

CommentFileSizeAuthor
#2 2961670-testonly.patch1.32 KBvalthebald

Comments

valthebald created an issue. See original summary.

valthebald’s picture

Status: Active » Needs review
StatusFileSize
new1.32 KB

Attached is the test-only patch (expected to fail)

Status: Needs review » Needs work

The last submitted patch, 2: 2961670-testonly.patch, failed testing. View results

miro_dietiker’s picture

Didn't test this in detail, but the revision tabs are filtered: They only show the revisions that affected the current user interface language.

Did you check the revision tab with switching the languages?

IMHO the tab should by default list all revisions with an optional exposed filter to limit the languages. The current behavior is highly confusing and frustrating users.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kunalkursija’s picture

Tried "steps to reproduce" and confirming the behavior mentioned in the issue is true.

In Drupal 7, It seems like language change in node was not tracked in revisions. This resulted in all revisions of the node irrespective of the language being visible on the revisions listing page. Whereas Drupal 8 onwards, The node's language change is tracked and revisions that belong to the translation are only visible.

Looks like for Drupal 8 onwards this is an intentional behavior as language code is what differentiates one translation from another, Whereas in Drupal 7 it used to be nid's that varied from translation to translation.

I am not sure what the actual behavior should be.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.