-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Debug] Handled errors #10725
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Debug] Handled errors #10725
Conversation
It looks rather than bugfix than new feature). Any chance merge this ti 2.3/2.5? |
Did it work before: not ideally from a user land pov, but yes => not a bug |
I think this could still go in 2.5 as part of the stabilization phase |
Just retagged as bug fix, hopping like you that it can go through 2.5 ;-) I also pushed an important code update: fatal errors also are now re-injected in the As a consequence, the web toolbar and all the other usual sweetness will work again. The code is resistant to any second fatal error that might happen while doing this re-injection thanks to a pre-buffering technique implemented by HandledErrorException: in the worst case, the response will be the same degraded one as before. As a corollary, the stack trace is now fixed for fatal errors when xdebug is enabled. Before: After: |
* @param object $object Any object | ||
* @param string $method A method name that will be called on $object with a FatalErrorException as argument | ||
*/ | ||
public static function setFatalErrorExceptionHandler($object, $method) |
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.
Please use a single argument accepting a callable. This way, any callable will be supported (the code already supports all types of callables internally)
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.
But I need dependency injection from the container builder...
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.
<service>
<argument type="collection">
<argument type="service" id="http_kernel" />
<argument>handleFatalErrorException</argument>
</argument>
</service>
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.
Agree with stof
You should probably update changelogs to mention deprecations |
$trace = array_slice(array_reverse($trace), 1); | ||
} | ||
} | ||
$trace = array_slice(array_reverse($trace), 1); |
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.
this is now sliced for all exceptions, not only fatal ones. Is it intended ?
... and tests do not pass. |
Hum... fixed! |
Great job @nicolas-grekas |
Since several phpdoc were missing, I wouldn't have merged it yet. |
…t/54275 (nicolas-grekas) This PR was merged into the 2.5-dev branch. Discussion ---------- [Debug] less intrusive work around for https://bugs.php.net/54275 | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #10787, #10292 | License | MIT | Doc PR | none - This PR supersedes the behavior introduced in #10725 : Instead of building some complicated code to work around https://bugs.php.net/54275, the code is now as straightforward as possible, with a conditional fallback work around. - The handling of fatal errors is also made more robust/fail-safe. - Last but not least, ErrorsLoggerListener and FatalErrorExceptionsListener are now registered earlier and are now cleaning up their handler/logger once set to prevent setting again and again for sub-requests (+remove one refcount for these handler and logger). Commits ------- d7a186f [Debug] less intrusive work around for https://bugs.php.net/54275
Enhance error handling and thus displaying for catchable PHP errors.
Code is tricky thanks to https://bugs.php.net/54275
Before:
After: