Problem/Motivation
Originally, some work was started in #2430335: Browser language detection is not cache aware to resolve a caching issue. A language redirect was introduced, but the implementation was more general than just adding the language prefix. The target redirect URL was constructed from current route. This caused some test fails (especially, in case if this redirect is enabled always even if the language module is not installed, see 2430335#89). And this issue was created.
Current implementation
There is a new route_normalizer_request_subscriber service that perform redirects like the Global Redirect module. On a GET request, it construct a URL from the current route and the current route/query parameters, and redirects to that URL if it does not match the incoming URL. This causes:
- language redirect, for example from "/" to "/en", this resolves #2430335: Browser language detection is not cache aware
- path alias redirect, for example from "node/1" to "content/my-node"
- front page redirect, for example from "/node" to "/"
There can be more cases, but they are unknown at the moment.
Also, the patch contains some fixes for bugs caught during development, and some documentation changes.
Arguments for this feature:
- globalredirect has a lot of installations, people might need this feature in the core
- better SEO
- less cache entries
- it allows to catch bugs at early development stage (check the fixes provided in the patch)
Remaining tasks
+ fix remaining test fails
+ write tests
- decide if we need this feature, if yes:
- which release? (btw, bug-fixes from the patch probably can be committed to the current release)
- should there be a possibility to disable the normalizer service from the UI?
User interface changes
The default Drupal installation will behave like the one having the Global Redirect module enabled.
API changes
The "disable_route_normalizer" request attribute can be set to disable the route normalization:
<?php
$request->attributes->set('disable_route_normalizer', TRUE);
?>
Data model changes
none