Search path is accesible in all languages

Created on 12 December 2023, about 1 year ago
Updated 19 December 2023, 12 months ago

Problem/Motivation

In a multi-language configuration, the search paths are accessible in all languages. This behavior can be a bit confusing, as it is expected that the search path corresponds to the current language of the page.

If it's a search page whose path exists but the current language doesn't match the language of the path, a 404 error should be returned.

On the other hand, when dynamic routes are generated, the path for the default language does not properly capture the configured path for the search page.

Steps to reproduce

  1. Set up the website in multi-language mode.
  2. Translate the "label" and "path" search into various languages via configuration (admin/config/search/search-api-pages/search/translate), for example, in french label could be "Rechercher" and path: "rechercher"
  3. Clear the website cache (preferably use drush cr).
  4. Access a search path in the default language, assuming it is English: https://www.example.com/search
  5. Access the search path in a translated language (e.g., French): https://www.example.com/fr/rechercher
  6. If you access the path: "https://www.example.com/fr/search," you will see that it is possible and can be confusing. It may be desirable to return a 404 error.

Proposed resolution

  • Adjust the controller to ensure that if the search route does not match the current language, the website will return a 404 error.
  • When the path is empty, its default value will align with the path defined in the base configuration of the search page, not with the one for the current language.
🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇪🇸Spain thebrokenbrain Las Palmas de Gran Canaria

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

Comments & Activities

Production build 0.71.5 2024