* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/** @ignore */
if (!defined('IN_PHPBB') || !defined('IN_INSTALL'))
{
exit;
}
function phpbb_require_updated($path, $phpbb_root_path, $optional = false)
{
$new_path = $phpbb_root_path . 'install/update/new/' . $path;
$old_path = $phpbb_root_path . $path;
if (file_exists($new_path))
{
require($new_path);
}
else if (!$optional || file_exists($old_path))
{
require($old_path);
}
}
function phpbb_include_updated($path, $phpbb_root_path, $optional = false)
{
$new_path = $phpbb_root_path . 'install/update/new/' . $path;
$old_path = $phpbb_root_path . $path;
if (file_exists($new_path))
{
include($new_path);
}
else if (!$optional || file_exists($old_path))
{
include($old_path);
}
}
function installer_msg_handler($errno, $msg_text, $errfile, $errline)
{
global $phpbb_installer_container, $msg_long_text;
// 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;
}
// If the message handler is stripping text, fallback to the long version if available
if (!$msg_text && !empty($msg_long_text))
{
$msg_text = $msg_long_text;
}
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;
if (!empty($phpbb_installer_container))
{
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);
}
}
else
{
print($msg);
}
return;
break;
case E_USER_ERROR:
$msg = 'General Error:
' . $msg_text . '
in file ' . $errfile . ' on line ' . $errline . '
';
if (!empty($phpbb_installer_container))
{
try
{
/** @var \phpbb\install\helper\iohandler\iohandler_interface $iohandler */
$iohandler = $phpbb_installer_container->get('installer.helper.iohandler');
$iohandler->add_error_message($msg);
$iohandler->send_response(true);
exit();
}
catch (\phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception $e)
{
throw new \phpbb\exception\runtime_exception($msg);
}
}
throw new \phpbb\exception\runtime_exception($msg);
break;
case E_DEPRECATED:
return true;
break;
}
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 && is_writable($cache->cache_dir))
{
$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 phpBB support forums.');
}
}
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 '';
echo '';
echo '