Problem/Motivation

If an entity instance has translations, only the original language link is fetched.
For example, if a node is originally written in spanish and has an english translation, when this content is referenced from another english node using ckeditor_entity_link, instead of the english path, the spanish one is retrieved.

Proposed resolution

Get the translated entity depending on the current viewed language and context Using entity.repository service.

Remaining tasks

A fix patch is included for review. I did some minor refactoring for related deprecated methods.

Greetings,

Comments

no74h created an issue. See original summary.

no74h’s picture

StatusFileSize
new3.85 KB

Added patch and did some refactoring

no74h’s picture

grimreaper’s picture

Assigned: Unassigned » grimreaper

Hello,

Testing the patch.

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Needs review » Reviewed & tested by the community
+++ b/src/Form/CKEditorEntityLinkDialog.php
@@ -126,14 +159,16 @@ class CKEditorEntityLinkDialog extends FormBase implements BaseFormIdInterface {
+      $entity = \Drupal::entityTypeManager()

This needs dependency injection but that's not the subject of this issue and you have done dependency injection for the new servie you use.

Tested without the patch, I have been able to reproduce the bug.

Tested with the patch applied. I confirm it solves the bug.

Thanks :)

no74h’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new4.12 KB

Thank you Grimreaper.
I added a second patch to fix UndefinedLinkTemplateException related to file Entity. File Entity still doesn't implement toUrl in core.
'No link template 'canonical' found for the 'file' entity type '.
It's related to the previously added $entity->toUrl() in the first patch.

Thank you!

martinma’s picture

Great work

Could reproduce the bug.

Applied patch #6 and it worked!
Linking to files worked too

Maybe batchfile without email header would make applying it more handy.

martinma’s picture

Status: Needs review » Reviewed & tested by the community
dealancer’s picture

Status: Reviewed & tested by the community » Needs work

Can not apply this patch anymore to the current head.

mrinalini9’s picture

Status: Needs work » Needs review
StatusFileSize
new3.63 KB

Rerolled patch #6 for 8.x-1.x branch, please review.

  • dealancer committed 79aa8a5 on 8.x-1.x authored by mrinalini9
    Issue #3056777 by no74h, mrinalini9: Get the translated entity instead...
  • dealancer committed c00c923 on 8.x-1.x authored by mrinalini9
    Issue #3056777 by no74h, mrinalini9, dealancer: Resolve conflict
    
dealancer’s picture

Status: Needs review » Fixed

@mrinalini9 good job!

grimreaper’s picture

Hello,

@dealancer this is great that this issue had been fixed.

I only have two questions/remarks:

  • I do not understand why the commit author is not @no74h because he (gender not assumed, I know him) made the original patch and reworked of the patch
  • I do not understand why @MartinMa and myself had not been credited for review and testing.
no74h’s picture

Hi, thank you all for the great work. Good Job!
Thanks @Grimreaper ;)

Status: Fixed » Closed (fixed)

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