LanguageNegotiationContentEntity: make language switch links more robust

Created on 6 April 2017, about 8 years ago
Updated 23 January 2023, over 2 years ago

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.

📌 Task
Status

Needs work

Version

9.5

Component
Language module 

Last updated about 4 hours ago

  • Maintained by
  • 🇩🇪Germany @sun
Created by

🇮🇹Italy ao2

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

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.

  • 🇺🇸United States smustgrave

    This 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.

Production build 0.71.5 2024