-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
Do not capture E_ERROR type as fatal error #514
Conversation
935a063
to
0baca06
Compare
I'll test this ASAP! Maybe we can add a thing to this PR: update the PHPDoc of the sentry-php/lib/Raven/Client.php Lines 561 to 570 in 0baca06
What do you think? |
Also: maybe we should add a (unit) test? |
I think that's a good idea. For reference: why not remove |
@Jean85 I changed the test to check if the output of the |
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.
Apart from my single comment, I tested this and it works! Great! 👍
lib/Raven/ErrorHandler.php
Outdated
// Do not capture E_ERROR since those can be caught by userland since PHP 7.0 | ||
// E_ERROR should already be handled by the exception handler | ||
// This prevents duplicated exceptions in PHP 7.0+ | ||
if (version_compare(phpversion(), '7.0', '>=') && $type === E_ERROR) { |
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.
Maybe if (PHP_VERSION_ID >= 70000)
is faster? That constant is available since PHP 5.2, so that's not an issue to use it.
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.
Looks like my PhpStorm inspections thought the same way. I changed it everywhere to stay consistent (updating the tests as we speak).
Sorry, I missed the changed test, I think it's enough for now! |
9ad8ba1
to
4913c1f
Compare
What are you all doing to capture fatal PHP errors, such as allowed memory size exhausted? To capture this fatal error successfully, I had to comment out the
sample code:
|
This should fix #408, can you guys please test it and and let me know if this is the way we should handle this or an alternative.
IMO this gist is that we should ignore E_ERROR exceptions as fatal in PHP 7.0+ since they can be captured by userland and are thus going through the regular exception handler before entering the fatal error handler thus creating duplicated exceptions.
This PR as a side effect also unifies the way the PHP version is checked.