diff options
| author | Damien Regad <dregad@mantisbt.org> | 2023-06-10 16:37:46 +0200 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2023-06-10 16:37:46 +0200 |
| commit | 943ac8a7de20117d85860a9b67f9eb65c5dfe4d7 (patch) | |
| tree | 7aa0e0fcc07ed0da04b49ee4f15259c2b22f0ce2 /adodb-exceptions.inc.php | |
| parent | 86234de5e0b1fc2786a7538497c8f0c50434934f (diff) | |
| download | adodb-943ac8a7de20117d85860a9b67f9eb65c5dfe4d7.tar.gz adodb-943ac8a7de20117d85860a9b67f9eb65c5dfe4d7.tar.bz2 adodb-943ac8a7de20117d85860a9b67f9eb65c5dfe4d7.zip | |
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
Diffstat (limited to 'adodb-exceptions.inc.php')
| -rw-r--r-- | adodb-exceptions.inc.php | 16 |
1 files changed, 12 insertions, 4 deletions
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); } |
