Require errorReportingLevel to be a subset of error_reporting #611
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
PHP 8 has changed how the
@
operator works:Previously,
error_reporting
would return '0' if@
is used but in PHP 8 it can now return any combination of fatal error types, depending on which were enabled (see https://3v4l.org/Z2lfD)This means that our current check for the
@
operator will no longer work so we need an alternative in order to fully support PHP 8. This is made more complicated because we have a second, Bugsnag only error level (errorReportingLevel
), otherwise this would be a simple changeDesign
Quite a few options were explored, but eventually we decided that the best way to solve this is to require that Bugsnag's
errorReportingLevel
is a subset oferror_reporting
— i.e. every error level inerrorReportingLevel
must also be inerror_reporting
This allows us to check if something has been silenced by checking against
error_reporting
first — if the error code is not inerror_reporting
then it has either been silenced or was never being reported to begin withIf
errorReportingLevel
is not a subset oferror_reporting
, a warning will be logged and all errors of the incorrect level(s) will be ignoredFor example, this would be valid usage of
errorReportingLevel
because everything inerrorReportingLevel
is also inerror_reporting
:However, this would be invalid usage of
errorReportingLevel
becauseE_WARNING
is not inerror_reporting
but is inerrorReportingLevel
:As before, setting
errorReportingLevel
to0
will ignore all errors and setting it tonull
(or not setting it at all) will useerror_reporting
insteadWe decided to implement this universally across PHP versions, so that there's not an unexpected change in Bugsnag's behaviour when going from PHP 7 → 8
Changeset
Configuration::setErrorReportingLevel
now validates the given level is a subset oferror_reporting
Configuration::shouldIgnoreErrorCode
uses a PHP 8 compatible way to check for@
, enabled by the above changeErrorTypes