Do not convert external URL to internal URI, when linking to a node from a different language context as current request.

Created on 14 May 2024, about 2 months ago
Updated 16 May 2024, about 1 month ago

Applies to Linkit field widget (not CKEditor):

Problem/motivation

External links from the same domain, but within different language contexts, are treated as "internal", and as a result - are stored as internal:/node/NID in the database. Then, when displaying, it might lead to situations, when a rendered link is displayed in a wrong language context.

Steps to reproduce

  1. Have a multilanguage website with at least two languages. For example, "sv" and "en". There is no lang prefix for "sv", and there is a "/en/" language prefix for "en" language.
  2. When being on a Swedish node edit page, try to link to an English page from the same website - but not from an autocomplete results dropdown, but as an external URL.
  3. When the node is submitted (and link form values have been "massaged" by a LinkitWidget::massageFormValues() - it gets automatically transformed to an internal URI, despite the link has been inserted as external.

Maybe it should work like that, when, indeed, the external URL points to the same language as the current request language. But if compared to a default "Link" field widget, provided by core - that widget does not convert external URLs to internal.

Proposed resolution

Providing a patch, which converts external URLs only in case it points to the same language as the current request language. Otherwise, IMHO, it makes no sense to convert it to internal, as later on, when displaying a link in a formatter/template - it will lead
to a situation when a link does not take into account a language prefix of a linked internal node.

πŸ› Bug report
Status

Needs review

Version

7.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine Stockticker

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024