Generic Revision UI's Revision overview page generates wrong operations/view links for a translation

Created on 26 April 2023, over 1 year ago
Updated 28 September 2023, about 1 year ago

Problem/Motivation

Generic Revision UI(implemented in Implement a generic revision UI Fixed ) is available in D10.1. The operation/view links for a translation on the revision overview page (provided by core\lib\Drupal\Core\Entity\Controller\VersionHistoryController.php) point to default language.

Steps to reproduce

1. Implement/extend Generic revision UI for a translatable entity.
2. Create a new content and translate it. Create few revisions for both source and translation.
3. Go to Revision Overview page of the translation and check view and operation links.
4. The links on Revision overview page of translation are wrong (links contain default language urls instead of current language urls)


For a site with Generic revision UI implemented for Bricks and having English(default) and French language. The view/revert/delete links for French translation of a brick entity with id 1 and revision id 7 are generated as:

/brick/1/revisions/7/view
/brick/1/revisions/7/revert
/brick/1/revisions/7/delete

But should be generated as:

/fr/brick/1/revisions/7/view
/fr/brick/1/revisions/7/revert
/fr/brick/1/revisions/7/delete

Proposed resolution

VersionHistoryController::loadRevisions() should return $revsion entity of current language (so that when toUrl() method is called on $revision, it returns appropriate language url).

--- a/core/lib/Drupal/Core/Entity/Controller/VersionHistoryController.php
+++ b/core/lib/Drupal/Core/Entity/Controller/VersionHistoryController.php
@@ -222,7 +222,7 @@ protected function loadRevisions(RevisionableInterface $entity) {
       // Only show revisions that are affected by the language that is being
       // displayed.
       if (!$translatable || ($revision->hasTranslation($currentLangcode) && $revision->getTranslation($currentLangcode)->isRevisionTranslationAffected())) {
-        yield $revision;
+        yield $revision->getTranslation($currentLangcode);
       }
     }
   }
🐛 Bug report
Status

Fixed

Version

10.1

Component
Entity 

Last updated 16 minutes ago

Created by

🇮🇳India sumit_saini

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

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024