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
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:
- 3356684-11.x changes, plain diff MR !4777
- 3356684-generic-revision-uis changes, plain diff MR !3882
Comments
Comment #3
sumit saini CreditAttribution: sumit saini as a volunteer commentedComment #4
sumit saini CreditAttribution: sumit saini as a volunteer commentedComment #5
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis caused some failures.
Will also need it's own test case / assertion showing it's an issue.
Comment #9
acbramley CreditAttribution: acbramley at PreviousNext commentedAdded 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.
Comment #10
smustgrave CreditAttribution: smustgrave at Mobomo commented@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
Comment #11
acbramley CreditAttribution: acbramley at PreviousNext commentedComment #13
smustgrave CreditAttribution: smustgrave at Mobomo commentedWas 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.
Comment #14
larowlan#2031223: Add linkByHrefExistsExact and linkByHrefNotExistsExact for matching links by href exactly is in, so let's use that here.
Comment #15
larowlanThat issue was reverted so putting this back to RTBC
Comment #17
lauriiiCommitted b0ac814 and pushed to 11.x. Cherry-picked to 10.1.x as a non-disruptive bug fix. Thanks!