From 5b03cd422a0d77b8e420eab69aaabe6fa188f8a7 Mon Sep 17 00:00:00 2001 From: Ruben Calvo Date: Fri, 28 Jun 2024 21:15:51 +0200 Subject: [PATCH] [ticket/17356] Correctly handle errors hidden by at PHPBB-17356 --- phpBB/includes/functions.php | 10 +++++++++- phpBB/install/startup.php | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 1ca315275b5..3a034bc7ab1 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3028,8 +3028,16 @@ function msg_handler($errno, $msg_text, $errfile, $errline) global $phpbb_root_path, $msg_title, $msg_long_text, $phpbb_log; global $phpbb_container; + // https://www.php.net/manual/en/language.operators.errorcontrol.php + // error_reporting() return a different error code inside the error handler after php 8.0 + $suppresed = E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE; + if (PHP_VERSION_ID < 80000) + { + $suppresed = 0; + } + // Do not display notices if we suppress them via @ - if (error_reporting() == 0 && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE) + if (error_reporting() == $suppresed && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE) { return; } diff --git a/phpBB/install/startup.php b/phpBB/install/startup.php index 0f2b1a60a05..c0405ac0972 100644 --- a/phpBB/install/startup.php +++ b/phpBB/install/startup.php @@ -51,7 +51,15 @@ function installer_msg_handler($errno, $msg_text, $errfile, $errline) { global $phpbb_installer_container, $msg_long_text; - if (error_reporting() == 0) + // Acording to https://www.php.net/manual/en/language.operators.errorcontrol.php + // error_reporting() return a different error code inside the error handler after php 8.0 + $suppresed = E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE; + if (PHP_VERSION_ID < 80000) + { + $suppresed = 0; + } + + if (error_reporting() == $suppresed) { return true; }