1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-12 03:42:05 +02:00

Merge branch '3.3.x'

This commit is contained in:
Marc Alexander 2020-02-14 08:15:06 +01:00
commit 98e8654c8c
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
2 changed files with 130 additions and 16 deletions

View File

@ -85,13 +85,7 @@ function installer_msg_handler($errno, $msg_text, $errfile, $errline)
return;
break;
case E_USER_ERROR:
$msg = '<b>General Error:</b><br />' . $msg_text . '<br /> in file ' . $errfile . ' on line ' . $errline;
$backtrace = get_backtrace();
if ($backtrace)
{
$msg .= '<br /><br />BACKTRACE<br />' . $backtrace;
}
$msg = '<b>General Error:</b><br>' . $msg_text . '<br> in file ' . $errfile . ' on line ' . $errline . '<br><br>';
throw new \phpbb\exception\runtime_exception($msg);
break;
@ -103,17 +97,129 @@ function installer_msg_handler($errno, $msg_text, $errfile, $errline)
return false;
}
/**
* Register class loaders for installer
*
* @param string $phpbb_root_path phpBB root path
* @param string $phpEx PHP file extension
*/
function installer_class_loader($phpbb_root_path, $phpEx)
{
$phpbb_class_loader_new = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx);
$phpbb_class_loader_new->register();
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
$phpbb_class_loader->register();
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\convert\\', "{$phpbb_root_path}install/convert/", $phpEx);
$phpbb_class_loader->register();
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext->register();
}
/**
* Installer shutdown function. Tries to resolve errors that might have occured
* during execution of installer
*
* @param int $display_errors Original display errors value
*/
function installer_shutdown_function($display_errors)
{
$error = error_get_last();
if ($error)
{
// Restore original display errors value
@ini_set('display_errors', $display_errors);
// Manually define phpBB root path and phpEx. These will not be passed
// on from app.php
$phpbb_root_path = __DIR__ . '/../';
$phpEx = 'php';
installer_class_loader($phpbb_root_path, $phpEx);
$supported_error_levels = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_DEPRECATED;
$cache = new \phpbb\cache\driver\file(__DIR__ . '/../cache/installer');
$filesystem = new \phpbb\filesystem\filesystem();
if (strpos($error['file'], $filesystem->realpath($cache->cache_dir)) !== false)
{
$file_age = @filemtime($error['file']);
if ($file_age !== false && ($file_age + 60) < time())
{
$cache->purge();
$symfony_request = new \phpbb\symfony_request(new \phpbb\request\request(new \phpbb\request\type_cast_helper()));
header('Location: ' . $symfony_request->getRequestUri());
exit();
}
else
{
// Language system is not available
die('The installer has detected an issue with a cached file. Try reloading the page and/or manually clearing the cache to resolve the issue. If you require further assistance, please visit the <a href="https://www.phpbb.com/community/" target="_blank">phpBB support forums</a>.');
}
}
else if ($error['type'] & $supported_error_levels)
{
// Convert core errors to user warnings for trigger_error()
if ($error['type'] == E_CORE_ERROR || $error['type'] == E_COMPILE_ERROR)
{
$error['type'] = E_USER_ERROR;
}
else if ($error['type'] == E_CORE_WARNING)
{
$error['type'] = E_USER_WARNING;
}
try
{
installer_msg_handler($error['type'], $error['message'], $error['file'], $error['line']);
}
catch (\phpbb\exception\runtime_exception $exception)
{
echo '<!DOCTYPE html>';
echo '<html dir="ltr">';
echo '<head>';
echo '<meta charset="utf-8">';
echo '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
echo '<title>General Error</title>';
echo '<style type="text/css">' . "\n" . '/* <![CDATA[ */' . "\n";
echo '* { margin: 0; padding: 0; } html { font-size: 100%; height: 100%; margin-bottom: 1px; background-color: #E4EDF0; } body { font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; color: #536482; background: #E4EDF0; font-size: 62.5%; margin: 0; } ';
echo 'a:link, a:active, a:visited { color: #006699; text-decoration: none; } a:hover { color: #DD6900; text-decoration: underline; } ';
echo '#wrap { padding: 0 20px 15px 20px; min-width: 615px; } #page-header { text-align: right; height: 40px; } #page-footer { clear: both; font-size: 1em; text-align: center; } ';
echo '.panel { margin: 4px 0; background-color: #FFFFFF; border: solid 1px #A9B8C2; } ';
echo '#errorpage #page-header a { font-weight: bold; line-height: 6em; } #errorpage #content { padding: 10px; } #errorpage #content h1 { line-height: 1.2em; margin-bottom: 0; color: #DF075C; } ';
echo '#errorpage #content div { margin-top: 20px; margin-bottom: 5px; border-bottom: 1px solid #CCCCCC; padding-bottom: 5px; color: #333333; font: bold 1.2em "Lucida Grande", Arial, Helvetica, sans-serif; text-decoration: none; line-height: 120%; text-align: left; } ';
echo "\n" . '/* ]]> */' . "\n";
echo '</style>';
echo '</head>';
echo '<body id="errorpage">';
echo '<div id="wrap">';
echo ' <div id="acp">';
echo ' <div class="panel">';
echo ' <div id="content">';
echo ' <h1>General Error</h1>';
echo ' <div>' . $exception->getMessage() . '</div>';
echo ' </div>';
echo ' </div>';
echo ' </div>';
echo ' <div id="page-footer">';
echo ' Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Limited';
echo ' </div>';
echo '</div>';
echo '</body>';
echo '</html>';
}
}
}
}
phpbb_require_updated('includes/startup.' . $phpEx, $phpbb_root_path);
phpbb_require_updated('phpbb/class_loader.' . $phpEx, $phpbb_root_path);
$phpbb_class_loader_new = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx);
$phpbb_class_loader_new->register();
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
$phpbb_class_loader->register();
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\convert\\', "{$phpbb_root_path}install/convert/", $phpEx);
$phpbb_class_loader->register();
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext->register();
installer_class_loader($phpbb_root_path, $phpEx);
// In case $phpbb_adm_relative_path is not set (in case of an update), use the default.
$phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/';
@ -129,6 +235,12 @@ 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 : 'installer_msg_handler');
$php_ini = new \bantu\IniGetWrapper\IniGetWrapper();
$ini_display_errors = $php_ini->getNumeric('display_errors');
register_shutdown_function('installer_shutdown_function', $ini_display_errors);
// Suppress errors until we have created the containers
@ini_set('display_errors', 0);
$phpbb_installer_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx);
$phpbb_installer_container_builder
@ -142,3 +254,5 @@ $phpbb_installer_container = $phpbb_installer_container_builder
->with_config_path($config_path)
->with_custom_parameters(array('cache.driver.class' => 'phpbb\cache\driver\file'))
->get_container();
@ini_set('display_errors', $ini_display_errors);

View File

@ -599,7 +599,7 @@ class filesystem implements filesystem_interface
}
/**
* Try to resolve real path when PHP's realpath failes to do so
* Try to resolve real path when PHP's realpath fails to do so
*
* @deprecated 3.3.0-a1 (To be removed: 4.0.0)
*