From 943ac8a7de20117d85860a9b67f9eb65c5dfe4d7 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Sat, 10 Jun 2023 16:37:46 +0200 Subject: Fix adodb_throw() ignoring @ operator on PHP 8 error_reporting()'s return value for suppressed errors changed from 0 to 4437 in PHP 8.0.0 [1]. As a result, adodb_throw() throws exceptions when it is not expected to. Fixes #981 [1]: https://www.php.net/manual/en/language.operators.errorcontrol.php --- adodb-exceptions.inc.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'adodb-exceptions.inc.php') diff --git a/adodb-exceptions.inc.php b/adodb-exceptions.inc.php index 36566de4..e4fae817 100644 --- a/adodb-exceptions.inc.php +++ b/adodb-exceptions.inc.php @@ -81,10 +81,18 @@ var $database = ''; function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection) { -global $ADODB_EXCEPTION; + global $ADODB_EXCEPTION; + + // 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; + } + + $errfn = is_string($ADODB_EXCEPTION) ? $ADODB_EXCEPTION : 'ADODB_EXCEPTION'; - if (error_reporting() == 0) return; // obey @ protocol - if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION; - else $errfn = 'ADODB_EXCEPTION'; throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection); } -- cgit v1.3