From 50db1018c3d2ac9ef73aeaf0bb545d606c88f7f3 Mon Sep 17 00:00:00 2001 From: Nathan Gibbs Date: Mon, 12 Jun 2023 09:43:06 -0400 Subject: [PATCH] Respect @ operator in all error handlers on PHP 8 error_reporting()'s return value for suppressed errors changed from 0 to 4437 in PHP 8.0.0 [1]. Follow up on commit 943ac8a7de20117d85860a9b67f9eb65c5dfe4d7. Fixes #981 (PR #984) --- adodb-errorhandler.inc.php | 9 ++++++++- adodb-errorpear.inc.php | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/adodb-errorhandler.inc.php b/adodb-errorhandler.inc.php index 0cd3f218b..1d3b9e9e5 100644 --- a/adodb-errorhandler.inc.php +++ b/adodb-errorhandler.inc.php @@ -37,7 +37,14 @@ */ function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) { - if (error_reporting() == 0) return; // obey @ protocol + // Do not throw if errors are suppressed by @ operator + // error_reporting() value for suppressed errors changed in PHP 8.0.0 + $suppressed = version_compare(PHP_VERSION, '8.0.0', '<') + ? 0 + : E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE; + if (error_reporting() == $suppressed) { + return; + } switch($fn) { case 'EXECUTE': $sql = $p1; diff --git a/adodb-errorpear.inc.php b/adodb-errorpear.inc.php index 2bb15947e..7b173da84 100644 --- a/adodb-errorpear.inc.php +++ b/adodb-errorpear.inc.php @@ -52,7 +52,15 @@ function ADODB_Error_PEAR($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false) { global $ADODB_Last_PEAR_Error; - if (error_reporting() == 0) return; // obey @ protocol + // Do not throw if errors are suppressed by @ operator + // error_reporting() value for suppressed errors changed in PHP 8.0.0 + $suppressed = version_compare(PHP_VERSION, '8.0.0', '<') + ? 0 + : E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE; + if (error_reporting() == $suppressed) { + return; + } + switch($fn) { case 'EXECUTE': $sql = $p1;