CommentLazyBuilders should be language aware

Created on 6 May 2020, about 4 years ago
Updated 24 February 2023, over 1 year ago

Problem/Motivation

CommentLazyBuilders always check the default entity language. Even when you view a comment translation you will get links to the default language instead of the translation you are viewing.

Steps to reproduce

  1. Install drupal using standard install profile
  2. Make your comment type translatable
  3. Create a comment and then translate it
  4. View the comment translation, e.g. visit /fr/comment/1
  5. Inspect the local tasks links, you will see that they point to the default language, like /comment/1/edit instead of the translation /fr/comment/1/edit

Proposed resolution

  • Make sure correct language version of the comment entity is loaded before links are rendered. At least Edit and Delete links should be directed to the displayed entity language.

Remaining tasks

  • Decide how to handle Reply, Approve and Translate.
  • Review and commit patch.

User interface changes

  • Comment entity links will direct to correct language version.

API changes

  • None.

Data model changes

  • None.

Release notes snippet

🐛 Bug report
Status

Needs work

Version

10.1

Component
Comment 

Last updated 2 days ago

Created by

🇳🇴Norway matsbla

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.

  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
    +++ b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php
    @@ -234,4 +235,49 @@ protected function doTestTranslationEdit() {
    +      if (!$comment->hasTranslation($langcode)) {
    +        $options = ['language' => \Drupal::languageManager()->getLanguage($default_langcode)];
    +      }
    

    I think we should also assert that $options['language'] doesn't equal the default langcode for all except $default_langcode and $not_translated_langcode

  • 🇮🇳India Prem Suthar gujrat

    Re-roll the patch For 10.1

Production build 0.69.0 2024