Needs work
Project:
Drupal core
Version:
main
Component:
comment.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
6 May 2020 at 17:59 UTC
Updated:
14 Oct 2025 at 02:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
matsbla commentedJust missed one link.
Comment #3
matsbla commentedComment #4
andypostInteresting catch, btw maybe language should be passed as argument?
Comment #5
matsbla commentedMaybe, but I think core should do it in a consistent way.
The approach in this patch is the same as what is used in NodeViewBuilder
https://git.drupalcode.org/project/drupal/-/blob/8.9.x/core/modules/node/src/NodeViewBuilder.php#L100
https://git.drupalcode.org/project/drupal/-/blob/8.9.x/core/modules/node/src/NodeViewBuilder.php#L136
Comment #6
andypostThanks, then let's keep it consistent!
NW for tests, probably node already have examples
Comment #7
matsbla commentedHere are tests.
Yes, I took some inspiration from the node tests here:
https://git.drupalcode.org/project/drupal/-/blob/8.8.x/core/modules/node/tests/src/Functional/NodeTranslationUITest.php#L290-346
Comment #8
matsbla commentedComment #9
matsbla commentedComment #11
matsbla commentedComment #12
jibranThanks, the patch looks good now.
Comment #13
andypostwhen translation is missing (whatever reason) this code will throw exception now
Comment #14
larowlanFor #13 can we add a try/catch there to be safe?
We have unit-test coverage of that class - can we extend CommentLinkBuilderTest for these cases too?
Comment #15
jungleOne nitpick/micro-optimization:
To avoid calling
$this->assert Session()multiple times in the loop. Every call returns a new instance.Suggestion:
Changing the target version to 9.1.x.
Comment #16
deepak goyal commentedComment #17
deepak goyal commentedHi @jungle
Made changes as you suggested please review.
Comment #18
deepak goyal commentedComment #20
matsbla commentedAdded try / catch to check if translation exists.
Should that also be done in NodeViewBuilder?
https://git.drupalcode.org/project/drupal/-/blob/8.9.x/core/modules/node/src/NodeViewBuilder.php#L100
Also updated test.
Comment #21
matsbla commentedComment #22
pratik_kambleComment #23
jungleThanks @matsbla for the new patch. Would be great to attach an interdiff when possible. See https://www.drupal.org/documentation/git/interdiff
Comment #24
matsbla commentedComment #25
pratik_kamble@matsbla, I have tested patch in the comment #20. Patch LGTM just one minor change.
Please add the description in the catch block. Say "Invalid translation language ($langcode) specified." or similarly something more descriptive.
Comment #26
pratik_kambleComment #27
matsbla commentedThanks for feedback!
Comment #28
matsbla commentedComment #29
pratik_kambleAssigning for review.
Comment #30
pratik_kambleTested patch in comment #27. Local task link for comments points to respective translation if present. It LGMT.
Comment #31
alexpottBut I'm not sure that that should block the work here as this change is inline with how entity translations are supposed to work. It's just more evidence that multilingual comments are not well supported or thought about from a core perspective.
No need to assign $translation here. It is never used.
Can be removed see below.
This could be written as
And then we can remove the base_path stuff above -I think this is a bit neater.
These assertions can be written like:
Using phpunit's more specific assertions over assertTrue is generally preferred.
And note it's no longer necessary to do
$assert_session = $this->assertSession();Comment #32
manisha111 commentedComment #33
manisha111 commentedAccording to the comment #31, patch added for point 2, 3, 4 and 5.
Please review.
Thanks & Regards
Manisha Bhawsar
Comment #35
hardik_patel_12 commentedComment #36
hardik_patel_12 commentedSolving failed test cases.
Comment #38
hardik_patel_12 commentedComment #39
matsbla commentedThanks a lot for the feedbacks, I think now all the mentioned issues should be fixed.
Comment #40
matsbla commentedComment #41
quietone commentedThanks everyone, there is getting there.
I started my review by reading the Issue Summary. It is nice to see there are steps to reproduce. They could be improved by starting from the install of Drupal whereas this starts from an existing comment type. If I were to test this my first question would be, what profile was used for the install? Next I was looking for some idea of what the fix is. That is not explained nor is there a 'proposed resolution' section. Also missing is 'remaining tasks', so as a reviewer I need to start from scratch. Please use dreditor and insert the issue summary template and complete it. Tagging needs issue summary update.
I have read through the issue and found that #15.1 is still to do. Setting NW for that.
The test creates two translations, 'it' and 'fr' and then tests rendering those translations. Without the fix the test fails because it has not loaded the 'it' translation. That is good to see. What I don't see is a test of case where the translation does not exist. A test for that needs to be added. Adding 'needs tests' for that.
And I have some of my own questions/comments.
Please add in alphabetical order as much is possible.
This is a tough read. Should it be 'Check that each local task links to the correct translation'?
Feels like this comment needs more information and $langcode is redundant. Maybe 'Ignore invalid translation language because ...'
Can be removed. $links is set in the third line below.
Comment #42
matsbla commentedThank you for the review.
Adding summary template.
Fixed #41.1-4.
In #31 @alexpott wrote
So from my understanding I don't think #15.1 is still to do.
Comment #43
matsbla commentedComment #44
matsbla commentedComment #45
matsbla commentedI'm attaching tests for when the translation does not exists.
However, I wonder how we in these cases should handle Reply, Approve and Translate links? I think it makes sense that Edit and Delete link directs you to the form in correct language. However, maybe the other mentioned links should stay in current interface language?
Comment #46
matsbla commentedComment #47
matsbla commentedSorry, here is correct interdiff
Comment #48
matsbla commentedComment #49
andypostI looks great! Just minor nitpics
Please file separate
test-only.patchto prove that test catching the bugMaybe
if ($entity->hasTranslation($langcode)) {..}will be less expensive instead of exceptionShould tell why token is stripped
Comment #50
matsbla commentedFixing 49.1-2
Thank you!
Comment #52
andypostKnown test failure, btw test-only should be uploaded before fixed one to not change status on failure
Comment #54
viappidu commentedRewrite for 9.1.x
Comment #58
borisson_This patch needs to be rerolled.
In #31, @alexpott mentioned the work going on in #2751269, that issue is still going on so I think we can still get this in when it is rerolled.
Comment #59
jungleComment #60
mrinalini9 commentedRerolled patch #54 for 9.5.x, please review it.
Comment #62
ravi.shankar commentedTrying to fix failed tests of patch #60.
Comment #64
larowlanI think we should also assert that $options['language'] doesn't equal the default langcode for all except $default_langcode and $not_translated_langcode
Comment #65
prem suthar commentedRe-roll the patch For 10.1
Comment #69
acbramley commentedRolled #65 into an MR, the test was failing on missing Reply links. I've removed that for now assuming that something has changed and this isn't expected anymore. #64 still needs actioning.