LanguageNegotiationUrl unnecessarily adds domain to outbound URL's

Created on 29 February 2024, 4 months ago
Updated 7 June 2024, 9 days ago

Problem/Motivation

Core does not always check if external URL's are local (using UrlHelper::externalIsLocal) which has varied consequences. We can avoid adding the base_path to outbound URL's by checking if the language negotiation path is the same as the current path and avoid some problems.

See 🐛 Cannot delete file when using language negotiation domains Active for full context.

Steps to reproduce

  1. Setup two domains (.ddev/config.yaml additional_hostnames, I used "local" and "es.local").
  2. Install Drupal, enable media and language modules.
  3. Add a language for the second domain on admin/config/regional/language (I used Spanish). Configure detection on admin/config/regional/language/detection, edit "URL", select "Domain", and set the two domain URL's (I used local.ddev.site and es.local.ddev.site)
  4. Add a media document from admin/content/media
  5. Visit admin/content/files and hover over the "Delete" link. Notice that it uses the full URL.

Proposed resolution

Add an additional check in LanguageNegotiationUrl::processOutbound() that returns early if the base_url's match.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Language system 

Last updated about 16 hours ago

  • Maintained by
  • 🇩🇪Germany @sun
Created by

🇺🇸United States douggreen Winchester, VA

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.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024