Skip to content
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

Possible Backwards Incompatible Change in 3.9 #2359

Closed
it-all opened this issue Dec 2, 2017 · 3 comments
Closed

Possible Backwards Incompatible Change in 3.9 #2359

it-all opened this issue Dec 2, 2017 · 3 comments

Comments

@it-all
Copy link

it-all commented Dec 2, 2017

My custom notFoundHandler works in 3.8.1 but not in 3.9.x. Now I just get the browser error. The redirect line doesn't work. Any idea on what changed and how I can fix it?

//Override the default Not Found Handler
'notFoundHandler' => function ($container) {
    return function ($request, $response) use ($container) {
        return $container['response']
            ->withStatus(404)
            ->withHeader('Content-Type', 'text/html')
            ->withRedirect($container->router->pathFor('pageNotFound'));
    };
}
@tflight
Copy link
Contributor

tflight commented Dec 2, 2017

See this discussion as it may pertain to your issue.

@akrabat
Copy link
Member

akrabat commented Dec 2, 2017

Browsers only automatically follow the Location header if you set the status to a 3xx code. You’re setting 404.

In 3.8.1 and below, there was a bug where the status code you set was not being honoured.

@it-all
Copy link
Author

it-all commented Dec 2, 2017

Ok, thanks.
It works when I remove the status and header lines and simply redirect:

//Override the default Not Found Handler
'notFoundHandler' => function ($container) {
    return function ($request, $response) use ($container) {
        return $container['response']
            ->withRedirect($container->router->pathFor('pageNotFound'));
    };
}

@it-all it-all closed this as completed Dec 2, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants