Skip to content

Commit

Permalink
Merge pull request phpbb#6661 from rubencm/ticket/17356
Browse files Browse the repository at this point in the history
[ticket/17356] Correctly handle errors hidden with at
  • Loading branch information
marc1706 committed Jul 5, 2024
2 parents 6798c33 + 5b03cd4 commit 48a233e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion phpBB/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 9 additions & 1 deletion phpBB/install/startup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 48a233e

Please sign in to comment.