LanguageNegotiationContentEntity::getLanguageSwitchLinks() should use copies of the URL instead of passing the reference directly, so that other modules can modify links individually, like adding attributes. I see that LanguageNegotiationUrl::getLanguageSwitchLinks() does that.
A use case is Entity translation switcher which gets the content language switcher links with \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_CONTENT, $url); and then adds some attributes; take a look at http://cgit.drupalcode.org/sandbox-ao2-2860238/tree/entity_translation_s...
Without cloning the URL, an attribute added to one link will be used also in all the other language switcher links.
A patch is on its way.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | LanguageNegotiationContentEntity_make_language_switch_links_more_robust-2867480-2.patch | 1.38 KB | ao2 |
Comments
Comment #2
ao2 commentedHere is a tentative patch.
While at it, also set the
languageoption to NULL, so that content language switch links get always rendered with the current interface language as URL prefix. The rationale is that they should never change the interface language, only the content language.Thanks,
Antonio
Comment #3
ao2 commentedComment #13
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Tagging for issue summary update for proposed solution and remaining tasks
Tagging for tests to show how the url can be altered.