From 115d0e794ebcded5b3e909e2eb8340146ada0d2f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 3 Feb 2020 17:44:54 +0100 Subject: [PATCH] [ticket/16354] Clean up startup a bit and add annotations PHPBB3-16354 --- phpBB/install/startup.php | 18 +++++++++++++++++- phpBB/phpbb/filesystem/filesystem.php | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/phpBB/install/startup.php b/phpBB/install/startup.php index 7c0ce5ecd2..be5a0fc223 100644 --- a/phpBB/install/startup.php +++ b/phpBB/install/startup.php @@ -103,6 +103,12 @@ 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); @@ -115,6 +121,12 @@ function installer_class_loader($phpbb_root_path, $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(); @@ -124,6 +136,8 @@ function installer_shutdown_function($display_errors) // 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'; @@ -131,7 +145,8 @@ function installer_shutdown_function($display_errors) $supported_error_levels = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_DEPRECATED; $cache = new \phpbb\cache\driver\file(__DIR__ . '/../cache/installer'); - if (strpos($error['file'], realpath($cache->cache_dir)) !== false) + $filesystem = new \phpbb\filesystem\filesystem(); + if (strpos($error['file'], $filesystem->realpath($cache->cache_dir)) !== false) { $file_age = @filemtime($error['file']); @@ -146,6 +161,7 @@ function installer_shutdown_function($display_errors) } 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.'); } } diff --git a/phpBB/phpbb/filesystem/filesystem.php b/phpBB/phpbb/filesystem/filesystem.php index 9acead0876..7f44d5f1de 100644 --- a/phpBB/phpbb/filesystem/filesystem.php +++ b/phpBB/phpbb/filesystem/filesystem.php @@ -637,7 +637,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 * * @param string $path * @return bool|string