Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpKernel][FrameworkBundle] Turn HTTP exceptions to HTTP status codes by default#27519
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas commentedJun 6, 2018
Status: needs review |
e6461da to1c9fc7aCompare
javiereguiluz left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I haven't tested it in a real app, but the code looks OK to me.
| publicfunctiontestNullController() | ||
| { | ||
| $listener =newExceptionListener(null); | ||
| $kernel =$this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
->getMockBuilder(HttpKernelInterface::class)->
Uh oh!
There was an error while loading.Please reload this page.
| private$isTerminating =false; | ||
| publicfunction__construct($controller,LoggerInterface$logger =null,$debug =false) | ||
| publicfunction__construct($controller,LoggerInterface$logger =null,$debug =false,$charset =null,$fileLinkFormat =null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
string $charset = null
dominikzogg commentedJun 27, 2018
@nicolas-grekas thanks, would be cool if you would backport this to all affected versions (3.4, 4.x) |
nicolas-grekas commentedJun 27, 2018
comments addressed thanks |
nicolas-grekas commentedJul 1, 2018
more comments @symfony/deciders ? |
…HTTP status codes by default (nicolas-grekas)This PR was merged into the 4.2-dev branch.Discussion----------[HttpKernel][FrameworkBundle] Turn HTTP exceptions to HTTP status codes by default| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#25844| License | MIT| Doc PR | -When an exception is thrown, *if it is not handled* then it will be reinjected as a 2nd exception event via `HttpKernel::terminateWithException()`. When this happens, this will generate a proper HTTP status code.Commits-------80b0739 [HttpKernel][FrameworkBundle] Turn HTTP exceptions to HTTP status codes by default
| if (!$event->isMasterRequest()) { | ||
| return; | ||
| } | ||
| if (!$this->isTerminating) { |
nicolas-grekasJun 5, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
for the record, the state managed by this property ensures that we don't break apps that handle exceptions outside of the stack:
try {$kernel->handle($request);}catch (SomeException$e) {// ...}
as required e.g. in some framework migration strategies.
As hinted in the PR description, this allows running the fallback exception logic only when no catch block stopped the bubbling, interminateWithException.
This reverts PRsymfony#27519 this commit18c2dde,reversing changes made toac1189a.
This reverts PRsymfony#27519 this commit18c2dde,reversing changes made toac1189a.
…las-grekas)This PR was merged into the 4.2 branch.Discussion----------[HttpKernel] Fix handling non-catchable fatal errors| Q | A| ------------- | ---| Branch? | 4.3| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | -| License | MIT| Doc PR | -This reverts PR#27519 this commit18c2dde,reversing changes made toac1189a.Right now, the listener is skipped on fatal errors.Commits-------a1619cc [HttpKernel] Fix handling non-catchable fatal errors
Uh oh!
There was an error while loading.Please reload this page.
When an exception is thrown,if it is not handled then it will be reinjected as a 2nd exception event via
HttpKernel::terminateWithException(). When this happens, this will generate a proper HTTP status code.