Problem/Motivation

Generic Revision UI(implemented in #2350939: Implement a generic revision UI) 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)

Example:
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);
       }
     }
   }

Issue fork drupal-3356684

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sumit_saini created an issue. See original summary.

sumit saini’s picture

Status: Active » Needs review
Issue tags: +Needs review
sumit saini’s picture

Assigned: sumit saini » Unassigned
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: -Needs review +Needs Review Queue Initiative, +Needs tests

This caused some failures.

Will also need it's own test case / assertion showing it's an issue.

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.

acbramley made their first commit to this issue’s fork.

acbramley’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

Added tests, and a bunch of links/handlers to EntityTestMulWithRevisionLog (copied directly from the parent EntityTestWithRevisionLog)

I looked at all our variations of EntityTest* classes and couldn't find another one that was translatable, revisionable, and had the revision route provider.

smustgrave’s picture

@acbramley reviewed the linkByHrefExactMatch ticket. May be close and could try and push it through if we wanted to postpone this one? Will leave in review

acbramley’s picture

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Was hoping https://www.drupal.org/project/drupal/issues/2031223 would of made it but as you noted shouldn't hold this up. Think the change makes sense and test coverage good.

Verified following the steps and MR 4777 works.

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
larowlan’s picture

Status: Needs work » Reviewed & tested by the community

That issue was reverted so putting this back to RTBC

  • lauriii committed b0ac814d on 11.x
    Issue #3356684 by sumit_saini, acbramley, smustgrave: Generic Revision...
lauriii’s picture

Version: 11.x-dev » 10.1.x-dev
Status: Reviewed & tested by the community » Fixed

Committed b0ac814 and pushed to 11.x. Cherry-picked to 10.1.x as a non-disruptive bug fix. Thanks!

  • lauriii committed 664eb630 on 10.1.x
    Issue #3356684 by sumit_saini, acbramley, smustgrave: Generic Revision...

Status: Fixed » Closed (fixed)

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