diff --git a/src/Config.php b/src/Config.php index 296542e3..2776f2bb 100644 --- a/src/Config.php +++ b/src/Config.php @@ -1001,7 +1001,28 @@ private function levelTooLow(Level $level): bool */ public function shouldSuppress(): bool { - return error_reporting() === 0 && !$this->reportSuppressed; + // report_suppressed option forces reporting regardless of PHP settings. + if ($this->reportSuppressed) { + return false; + } + + $errorReporting = error_reporting(); + + // For error control operator of PHP 8: + // > Prior to PHP 8.0.0, the error_reporting() called inside the + // > custom error handler always returned 0 if the error was + // > suppressed by the @ operator. As of PHP 8.0.0, it returns + // > the value E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | + // > E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE. + // https://www.php.net/manual/en/language.operators.errorcontrol.php + if (version_compare(PHP_VERSION, '8.0', 'ge') && $errorReporting === ( + E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE + )) { + return true; + } + + // PHP 7 or manually disabled case: + return $errorReporting === 0; } public function send(EncodedPayload $payload, string $accessToken): ?Response diff --git a/src/DataBuilder.php b/src/DataBuilder.php index a074354b..4af2cddd 100644 --- a/src/DataBuilder.php +++ b/src/DataBuilder.php @@ -178,7 +178,7 @@ protected function setLocalVarsDump($config) $fromConfig = isset($config['local_vars_dump']) ? $config['local_vars_dump'] : null; $this->localVarsDump = self::$defaults->localVarsDump($fromConfig); if ($this->localVarsDump && !empty(ini_get('zend.exception_ignore_args'))) { - ini_set('zend.exception_ignore_args', 'Off'); + ini_set('zend.exception_ignore_args', '0'); assert(empty(ini_get('zend.exception_ignore_args'))); } } diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index b4bf47d4..15b8da7d 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -382,6 +382,16 @@ public function testReportSuppressed($errorReporting, $configKey, $configValue, } } + public function testReportSuppressedActuallySuppressed() + { + $config = new Config(array( + 'report_suppressed' => false, + "access_token" => $this->getTestAccessToken() + )); + $this->assertFalse($config->shouldSuppress()); + $this->assertTrue(@$config->shouldSuppress()); + } + public function testFilter() { $d = m::mock("Rollbar\Payload\Data")