Domain based language negotiation stops AJAX facets from working

Created on 22 December 2022, almost 2 years ago
Updated 9 September 2023, about 1 year ago

Problem/Motivation

When the website is set to use "Domain" based URL language detection and you try to use facets from a facet source with a facets_pretty_path url processor, it doesn't work.

Steps to reproduce

  • Enable Domain based language url detection: /admin/config/regional/language/detection/url and fill in the urls for each enabled language.
  • Use a facet from a source that has been set to use facets_pretty_path (and AJAX)
  • The facet will appear to not work, reloading the page will display the error message e.g. "The user-entered string http://<site url>/<facet pretty path components> must begin with a '/', '?', or '#'."

This is because in Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl::processOutbound(), if the 'Domain' option is used, then the outbound site URLs are rewritten to use an absolute path.

Then, when in Drupal\facets_pretty_paths\PrettyPathsActiveFilters::getFiltersFromRoute() this line here:

$route_params = Url::fromUserInput($q)->getRouteParameters();

attempts to use the now absolute url with the Url::fromUserInput($q) call, which fails.

Proposed resolution

To solve this, i've gone with a relatively simple method of determining whether the site is using domain based language negotiation, and parsing $q to extract just the path, which is what it would be for a site that doesn't have domain based language negotiation set.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom rossb89 Bristol

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024