- Issue created by @krystalcode
- 🇵🇪Peru krystalcode
This is a patch as a starting point; you won't get the redirect trace with this. Other than that works fine for me and solves various issues such as support for redirects with query parameters.
Currently, the event subscriber that looks for matching redirects uses a custom query to pick up redirects for the given path. The Redirect module provides the \Drupal\redirect\RedirectRepository::findMatchingRedirect()
API method for this purpose. Not using it causes the following problems:
For example, redirects are supposed to respect query parameters and the way to identify redirect a matching redirect is by its hash. Decoupled Router not respecting this causing inconsistent - and actually buggy behavior - as the query to identify matching redirects is different than the one intended by Redirect.
Language is not taken into account in the query either.
The redirect chain is also determined with custom code here, and that - together with the above - opens up the possibility of Decoupled Router determining a different chain compared to Redirect.
Projects or contrib modules that need to customize redirects, for example, implementing redirects per domain, need to make changes in multiple places.
RedirectPathTranslatorSubscriber
should be using the redirect repository to find matching redirects. I don't deep knowledge of how and why Decoupled Router was developed this way, so I may be missing some things. What I currently see is that we include the redirect trace in the response, we may want to collaborate with the maintainers of the Redirect module to add a method that returns the trace together with the final redirect - since that is tracked internally already.
List the reasons why the redirect repository is not used to match redirects, and address those.
Active
2.0
Code
This is a patch as a starting point; you won't get the redirect trace with this. Other than that works fine for me and solves various issues such as support for redirects with query parameters.