From 151535fdaf52e2847074a861252d4f24850d2949 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Sat, 28 Nov 2015 12:43:58 +0100 Subject: [PATCH 1/2] [ticket/14311] Show errors in installer invoked by trigger_error PHPBB3-14311 --- phpBB/install/startup.php | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/phpBB/install/startup.php b/phpBB/install/startup.php index b40face4f8..ecf42a5ad0 100644 --- a/phpBB/install/startup.php +++ b/phpBB/install/startup.php @@ -47,6 +47,36 @@ function phpbb_include_updated($path, $phpbb_root_path, $optional = false) } } +function installer_msg_handler($errno, $msg_text, $errfile, $errline) +{ + switch ($errno) + { + case E_NOTICE: + case E_WARNING: + case E_USER_WARNING: + case E_USER_NOTICE: + $msg = '[phpBB debug] "' . $msg_text . '" in file ' . $errfile . ' on line ' . $errline; + throw new \phpbb\exception\runtime_exception($msg); + break; + case E_USER_ERROR: + $msg = 'General Error:
' . $msg_text . '
in file ' . $errfile . ' on line ' . $errline; + + $backtrace = get_backtrace(); + if ($backtrace) + { + $msg .= '

BACKTRACE
' . $backtrace; + } + + throw new \phpbb\exception\runtime_exception($msg); + break; + case E_DEPRECATED: + return true; + break; + } + + return false; +} + phpbb_require_updated('includes/startup.' . $phpEx, $phpbb_root_path); phpbb_require_updated('phpbb/class_loader.' . $phpEx, $phpbb_root_path); @@ -69,7 +99,7 @@ phpbb_require_updated('includes/functions_user.' . $phpEx, $phpbb_root_path); phpbb_require_updated('includes/utf/utf_tools.' . $phpEx, $phpbb_root_path); // Set PHP error handler to ours -set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); +set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'installer_msg_handler'); $phpbb_installer_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $phpbb_installer_container_builder From d1fc8f79e749cf48b2890335238c9867dc9abc05 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Tue, 1 Dec 2015 18:50:20 +0100 Subject: [PATCH 2/2] [ticket/14311] Use the iohandler for notices and warnings if possible PHPBB3-14311 --- phpBB/install/startup.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/phpBB/install/startup.php b/phpBB/install/startup.php index ecf42a5ad0..0d3e01efaa 100644 --- a/phpBB/install/startup.php +++ b/phpBB/install/startup.php @@ -49,6 +49,8 @@ function phpbb_include_updated($path, $phpbb_root_path, $optional = false) function installer_msg_handler($errno, $msg_text, $errfile, $errline) { + global $phpbb_installer_container; + switch ($errno) { case E_NOTICE: @@ -56,7 +58,17 @@ function installer_msg_handler($errno, $msg_text, $errfile, $errline) case E_USER_WARNING: case E_USER_NOTICE: $msg = '[phpBB debug] "' . $msg_text . '" in file ' . $errfile . ' on line ' . $errline; - throw new \phpbb\exception\runtime_exception($msg); + + try + { + /** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */ + $iohandler = $phpbb_installer_container->get('installer.helper.iohandler'); + $iohandler->add_warning_message($msg); + } + catch (\phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception $e) + { + print ($msg); + } break; case E_USER_ERROR: $msg = 'General Error:
' . $msg_text . '
in file ' . $errfile . ' on line ' . $errline;