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 | |
| 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
| -rw-r--r-- | adodb-exceptions.inc.php | 16 | ||||
| -rw-r--r-- | docs/changelog.md | 2 |
2 files changed, 14 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); } diff --git a/docs/changelog.md b/docs/changelog.md index fe31c216..597260b1 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -33,6 +33,8 @@ Older changelogs: [#966](https://github.com/ADOdb/ADOdb/issues/966) - Restore rs2html() $htmlspecialchars param behavior [#968](https://github.com/ADOdb/ADOdb/issues/968) +- adodb_throw() does not respect @ operator on PHP 8 + [#981](https://github.com/ADOdb/ADOdb/issues/981) - loadbalancer: PHP 8.2 warnings [#951](https://github.com/ADOdb/ADOdb/issues/951) - mysql: Fail connection if native driver (mysqlnd) is not available |
