Fix PHP 8 compatibility for WCF::handleError()
authorTim Düsterhus <duesterhus@woltlab.com>
Sun, 28 Jun 2020 13:50:05 +0000 (15:50 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sun, 28 Jun 2020 13:50:05 +0000 (15:50 +0200)
Quoting from the UPGRADING manual (https://github.com/php/php-src/blob/php-8.0.0alpha1/UPGRADING):

> 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:

wcfsetup/install/files/lib/system/WCF.class.php

index 1bcc9cde96f7a2162e9f5941b9cacd1a4fa2abdf..5f465eeab3f2d92f98791956372d8055631eb069 100644 (file)
@@ -336,7 +336,7 @@ class WCF {
         */
        public static final function handleError($severity, $message, $file, $line) {
                // this is necessary for the shut-up operator
-               if (error_reporting() == 0) return;
+               if (!(error_reporting() & $severity)) return;
                
                throw new ErrorException($message, 0, $severity, $file, $line);
        }