Skip to content

Conversation

@nicolas-grekas
Copy link
Member

Q A
Branch? 3.4
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #27212
License MIT
Doc PR -

#26138 introduced a BC break that is described in the linked issue.
In order to fix it, I propose to postpone generating a response for HTTP exceptions to the exception event that is throw in terminateWithException(). This allows providing the target DX (generate 404 for NotFoundHttpException) while allowing ppl that have custom listeners or try/catch to keep things working as previously.


public function onKernelException(GetResponseForExceptionEvent $event)
{
while (null === $this->controller) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a if rather than a while. It would be much easier to understand, and it can never loop anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using while allows using the break below :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while removed btw :)

@nicolas-grekas nicolas-grekas force-pushed the kernel-http-x branch 2 times, most recently from b9b3a8f to 76d532e Compare June 5, 2018 13:33
{
if (null === $this->controller) {
$terminating = false;
foreach (debug_backtrace() as $frame) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very much against this kind of code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I lacked a better idea, but this is fixed now.

@nicolas-grekas
Copy link
Member Author

Let's revert instead, see #27516
I'll reopen on master.

@nicolas-grekas nicolas-grekas deleted the kernel-http-x branch June 6, 2018 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants