-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Slim 4.10.0 redirects with status code 200 causing blank page #3177
Comments
I downgraded to Slim 4.9.0 and that fixed the redirect issue on my local development environment. |
To speed things up -- Caused by #1730 Commits 6aa522d and 1ma/jelly@c718132 |
Looks like you lost these tests from #2345 public function testStatusIsSetTo302IfLocationIsSetWhenStatusis200()
{
$response = new Response();
$response = $response->withHeader('Location', '/foo');
$this->assertSame(302, $response->getStatusCode());
}
public function testStatusIsNotSetTo302IfLocationIsSetWhenStatusisNot200()
{
$response = new Response();
$response = $response->withStatus(201)->withHeader('Location', '/foo');
$this->assertSame(201, $response->getStatusCode());
} |
I will stick with 4.9.0 for now |
The old behavior (before v4.10) was not correct because it was based on an implicit behavior of PHP. See here: #3139 |
I'm okay moving to the new version without the implicit 302, thanks for the link to the relevant PR. 👍 It might be worth mentioning with more prominence in the release notes as it could break a lot of production sites e.g. "The behaviour of all Location: redirects has changed you need to check all your redirects do not end up in a blank page". In my case login/logout etc were all broken and I only caught it because I was deep testing a feature. |
Hi Slim Developers,
Since I upgraded to 4.10.0, my redirects had status code 200. This broke my site with blank pages everywhere but luckily I caught it testing on the staging server.
To fix the issue I now specify
->withStatus(302)
when I do a redirect. See commented line below:I'm sharing this as an issue in case other people experience this issue.
Thanks again for an excellent framework.
Note: here is my full list of upgrades in case it wasn't caused by Slim (I feel this is unlikely though as they are unrelated)
The text was updated successfully, but these errors were encountered: