-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Routes with trailing slash broken after upgrade to 4.1.8 #29363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello, I just tried a 4.1.8 app with this exact controller, it works well. |
It seems I can only simulate it in my private repo as well. What I do notice, is that the route that is not working, is located in the $regexList of srcDevDebugProjectContainerUrlMatcher.php::doMatch. But I don't know what the reason is for a route to move there instead of the initial switch statement and can't simulate it with a test app. |
Hi, we can also confirm this from our end after the 4.1.8 update - none of the usual REST endpoints with trailing slashes work anymore and we experience the same behaviour as @jimmycleuren. Same as in his case, downgrading to 4.1.7 also fixes the issue. Not sure if it helps in identifying the problem, but setting redirection support to false will also fix the issue.
|
From @murnieza in #29287 (comment):
I'm on it. |
Hi everyone, please check #29373 and confirm it fixes your issues if you can. |
This PR was merged into the 4.1 branch. Discussion ---------- [Routing] fix trailing slash redirection | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29363 | License | MIT | Doc PR | - Commits ------- fbaba23 [Routing] fix trailing slash redirection
I have a similar issue on a project where routes with and without trailing slash both exist. With I added the following test to public function testNoRedirectWhenBothRoutesExist()
{
$coll = new RouteCollection();
$coll->add('foo_without_slash', new Route('/foo'));
$coll->add('foo_with_slash', new Route('/foo/'));
$matcher = $this->getUrlMatcher($coll);
$matcher->expects($this->never())->method('redirect');
$this->assertSame(array('_route' => 'foo_without_slash'), $matcher->match('/foo'));
$this->assertSame(array('_route' => 'foo_with_slash'), $matcher->match('/foo/'));
$coll = new RouteCollection();
$coll->add('foo', new Route('/foo{trailingSlash}', array(), array('trailingSlash' => '/?')));
$matcher = $this->getUrlMatcher($coll);
$matcher->expects($this->never())->method('redirect');
$this->assertSame(array('trailingSlash' => '', '_route' => 'foo'), $matcher->match('/foo'));
$this->assertSame(array('trailingSlash' => '/', '_route' => 'foo'), $matcher->match('/foo/'));
} which passes on v4.1.7 but fails on v4.1.8. I wasn't able to make it pass without breaking other tests though. |
@julienfalque AFAIK that behavior is consistent with how 3.4 behaves. If I'm not wrong, this means you relied on a bug that is now fixed. |
In my case, I get a redirection loop between the routes with and without the slash. It is not fixed by #29380, however. |
This PR was merged into the 4.1 branch. Discussion ---------- [Routing] fix greediness of trailing slash | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29363 | License | MIT | Doc PR | - Commits ------- eb6aee6 [Routing] fix greediness of trailing slash
#29380 updated, should fix them all. Please report back if not. |
Symfony version(s) affected: 4.1.8
Description
After the upgrade to 4.1.8, some routes with a trailing slash don't work anymore.
How to reproduce
The route "/user/" works in 4.1.7, but gives the following error in 4.1.8:
Additional context
Route is still visible in the debug:router command
Downgrade to 4.1.7 resolved the issue
The text was updated successfully, but these errors were encountered: