You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #26304 [Routing] support scheme requirement without redirectable dumped matcher (Tobion)
This PR was merged into the 4.1-dev branch.
Discussion
----------
[Routing] support scheme requirement without redirectable dumped matcher
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | yes
| BC breaks? | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets |
| License | MIT
| Doc PR |
The scheme handling was just redirecting immediately without testing the other routes at all for potential matches. This can cause Problems when you try to have different routes/controllers for the same path but different schemes. See added test.
```
$coll = new RouteCollection();
$coll->add('https_route', new Route('/', array(), array(), array(), '', array('https')));
$coll->add('http_route', new Route('/', array(), array(), array(), '', array('http')));
$matcher = $this->getUrlMatcher($coll);
$this->assertEquals(array('_route' => 'http_route'), $matcher->match('/'));
```
Instead of matching the right route, it would redirect immediatly as soon as it hits the first route.
This does not make sense and is not consistent with the other logic. Redirection should only happen when nothing matches. While fixing this I could also remove the limitation
> throw new \LogicException('The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.');
If redirection is not possible, the wrong scheme will just not match the route. This is the same as already implemented by UrlMatcher (not RedirecableUrlMatcher). If redirection is supported, it will redirect to the first supported scheme if no other route matches. This makes the implementation similar to redirection for trailing slash and handling not allowed methods.
Also previously, the scheme redirection was done for non-safe verbs which shouldn't happen as well, ref. #25962
Commits
-------
f9b54c5 [Routing] support scheme requirement without redirectable dumped matcher
0 commit comments