diff options
author | Chih-Hsuan Yen <yan12125@gmail.com> | 2021-06-23 20:24:21 +0800 |
---|---|---|
committer | Chih-Hsuan Yen <yan12125@gmail.com> | 2021-07-14 17:07:58 +0800 |
commit | 120fc8dd6a2bccebe4892b06ca399a62991682a2 (patch) | |
tree | 2407ffc910e517b200de3e0bf816aeb621819aa6 /lib/private | |
parent | ca96a03c6bd674e94cf329643aaa006845f10167 (diff) | |
download | nextcloud-server-120fc8dd6a2bccebe4892b06ca399a62991682a2.tar.gz nextcloud-server-120fc8dd6a2bccebe4892b06ca399a62991682a2.zip |
Correctly skip suppressed errors in PHP 8.0
Applies the suggested transformation mentioned in
https://www.php.net/manual/en/migration80.incompatible.php,
> The @ operator will no longer silence fatal errors (E_ERROR,
> E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR,
> E_PARSE). Error handlers that expect error_reporting to be 0 when
> @ is used, should be adjusted to use a mask check instead
The new code still works on PHP 7, as error_reporting() already
returns 0 when diagnostics are suppressed.
This fixes https://github.com/nextcloud/server/issues/25807 in PHP 8.0.
For PHP 7.x, https://github.com/nextcloud/server/pull/22243 suppresses
the E_NOTICE message from the second session_start() call with the error
suppression operator @, and thus those E_NOTICE messages are still
logged in PHP 8.0.
See also https://github.com/nextcloud/server/issues/25806
Signed-off-by: Chih-Hsuan Yen <yan12125@gmail.com>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Log/ErrorHandler.php | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/private/Log/ErrorHandler.php b/lib/private/Log/ErrorHandler.php index 6c969fa093c..d56fecb1ecb 100644 --- a/lib/private/Log/ErrorHandler.php +++ b/lib/private/Log/ErrorHandler.php @@ -85,7 +85,7 @@ class ErrorHandler { //Recoverable errors handler public static function onError($number, $message, $file, $line) { - if (error_reporting() === 0) { + if (!(error_reporting() & $number)) { return; } $msg = $message . ' at ' . $file . '#' . $line; |