From ff25f4905eefd6f17e2e999e83239bc0ff43dbf0 Mon Sep 17 00:00:00 2001 From: Dan Fuhry Date: Mon, 13 Jul 2020 10:22:35 -0400 Subject: [PATCH] Suppress notification if error_reporting() has narrowed If the error_reporting() setting has narrowed since Airbrake's error handler was installed, respect the new setting. This also resolves the issue of errors suppressed with the "@" operator being reported to Airbrake. (Fixes #105) --- src/ErrorHandler.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ErrorHandler.php b/src/ErrorHandler.php index 8ca42cb..2e15254 100644 --- a/src/ErrorHandler.php +++ b/src/ErrorHandler.php @@ -31,6 +31,13 @@ public function __construct(\Airbrake\Notifier $notifier) */ public function onError($code, $message, $file, $line) { + // If error_reporting() setting has changed since the ErrorHandler was + // installed, respect the new settings. This also respects the + // @-operator (issue #105) + if ($code !== (error_reporting() & $code)) { + return false; + } + $this->lastError = [ 'message' => $message, 'file' => $file,