Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpKernel] Fix php finally executing before handleThrowable()#47848

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
gnat42 wants to merge1 commit intosymfony:6.1fromgnat42:patch-47405

Conversation

@gnat42
Copy link
Contributor

QA
Branch?6.1
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#47405Fix#47358
LicenseMIT
Doc PR

Commite35d6ba causes some odd behaviour. What seems to be happening is a that the requestStack->pop() in the original commit in the finally{} catch is being executed before the handleThrowable() is called. This is most evident in#47358 where the LogoutUrlGenerator attempts to get a request from the requestStack but it is gone.

I verified using xdebug and breakpoints that the code in finally was being called first. With this patch, the original tests ine35d6ba continue to pass and my project where I reported the issue#47358 is not longer occurring.

@wouterj
Copy link
Member

Thanks for investigating this and creating a patch!

Commite35d6ba causes some odd behaviour. What seems to be happening is a that the requestStack->pop() in the original commit in the finally{} catch is being executed before the handleThrowable() is called.

I digged into this a bit more, as I don't like odd behavior 😃

What is important here is that the catch was only catchingException, notError. The one triggeringhandleThrowable() is a custom error handler. Apparently, if thetry { ... } block contains a PHP error, thefinally block is run before the error handler. I can reproduce this in a simple example:https://3v4l.org/mfgII

Unfortunately, I don't think we want to change the catch to\Exception|\Error like you did in this patch. This means the whole logic suddenly gets errors as well, instead of exceptions. That seems like a big BC break to me.

However, I'm unsure what to do here. To me, it seems like we should reverte35d6ba and find a way to somehow pop the request stack for errors as well, without finally block. Let's see if some of the PHP experts in the core team have a good suggestion here :)

@gnat42
Copy link
ContributorAuthor

Hey@wouterj yeah, that's precisely the issue. I wondered the same thing about the Throwable vs Exception. Glad for someone else to weigh in on this. One thing I'd note is that with my patch, I get what I would consider 'expected' behaviour. I get the normal symfony exception page with the stack trace etc

@carsonbotcarsonbot changed the titleFix php finally executing before handleThrowable()[HttpKernel] Fix php finally executing before handleThrowable()Oct 14, 2022
@nicolas-grekas
Copy link
Member

Should be fixed by#47857

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

6.1

Development

Successfully merging this pull request may close these issues.

4 participants

@gnat42@wouterj@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp