mirror of
https://github.com/phpbb/phpbb.git
synced 2025-01-18 06:38:43 +01:00
[ticket/14462] Further speed improvements
- Cache the secondary container - Only initialize tasks/modules that are being used - Add timeout error message in the AJAX UI PHPBB3-14462
This commit is contained in:
parent
0210a6298d
commit
955b9ede33
@ -12,6 +12,7 @@
|
||||
var progressTimer = null;
|
||||
var currentProgress = 0;
|
||||
var refreshRequested = false;
|
||||
var transmissionOver = false;
|
||||
|
||||
// Template related variables
|
||||
var $contentWrapper = $('.install-body').find('.main');
|
||||
@ -329,6 +330,12 @@
|
||||
if (responseObject.hasOwnProperty('redirect')) {
|
||||
redirect(responseObject.redirect.url, responseObject.redirect.use_ajax);
|
||||
}
|
||||
|
||||
if (responseObject.hasOwnProperty('over')) {
|
||||
if (responseObject.over) {
|
||||
transmissionOver = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -357,10 +364,21 @@
|
||||
$('#loading_indicator').css('display', 'none');
|
||||
resetPolling();
|
||||
|
||||
var timeoutDetected = !transmissionOver;
|
||||
|
||||
if (refreshRequested) {
|
||||
refreshRequested = false;
|
||||
doRefresh();
|
||||
}
|
||||
|
||||
if (timeoutDetected) {
|
||||
addMessage('error',
|
||||
[{
|
||||
title:'The installer detected a timeout.',
|
||||
description: 'The installer has detected a timeout, you may try to refresh the page, that may lead to data corruption. We suggest that you either increase your timeout settings or try to use the CLI.'
|
||||
}]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -420,6 +438,7 @@
|
||||
*/
|
||||
function startPolling(xhReq) {
|
||||
resetPolling();
|
||||
transmissionOver = false;
|
||||
pollTimer = setInterval(function () {
|
||||
pollContent(xhReq);
|
||||
}, 250);
|
||||
|
@ -53,6 +53,7 @@ services:
|
||||
phpbb.installer.controller.convert:
|
||||
class: phpbb\convert\controller\convertor
|
||||
arguments:
|
||||
- '@cache.driver'
|
||||
- '@installer.helper.container_factory'
|
||||
- '@installer.helper.database'
|
||||
- '@phpbb.installer.controller.helper'
|
||||
|
@ -89,6 +89,7 @@ services:
|
||||
- '@cache.driver'
|
||||
- '@installer.helper.config'
|
||||
- '@path_helper'
|
||||
- '@installer.helper.container_factory'
|
||||
|
||||
installer.install.module_collection:
|
||||
class: phpbb\di\ordered_service_collection
|
||||
@ -108,8 +109,10 @@ services:
|
||||
parent: installer.installer.abstract
|
||||
calls:
|
||||
- [set_modules, ['@installer.install.module_collection']]
|
||||
- [set_purge_cache_before, [false]]
|
||||
|
||||
installer.installer.update:
|
||||
parent: installer.installer.abstract
|
||||
calls:
|
||||
- [set_modules, ['@installer.update.module_collection']]
|
||||
- [set_purge_cache_before, [true]]
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
namespace phpbb\convert\controller;
|
||||
|
||||
use phpbb\cache\driver\driver_interface;
|
||||
use phpbb\exception\http_exception;
|
||||
use phpbb\install\controller\helper;
|
||||
use phpbb\install\helper\container_factory;
|
||||
@ -36,10 +37,15 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
class convertor
|
||||
{
|
||||
/**
|
||||
* @var \phpbb\cache\driver\driver_interface
|
||||
* @var driver_interface
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* @var driver_interface
|
||||
*/
|
||||
protected $installer_cache;
|
||||
|
||||
/**
|
||||
* @var \phpbb\config\db
|
||||
*/
|
||||
@ -123,6 +129,7 @@ class convertor
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param driver_interface $cache
|
||||
* @param container_factory $container
|
||||
* @param database $db_helper
|
||||
* @param helper $controller_helper
|
||||
@ -135,8 +142,9 @@ class convertor
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $php_ext
|
||||
*/
|
||||
public function __construct(container_factory $container, database $db_helper, helper $controller_helper, install_helper $install_helper, factory $iohandler, language $language, navigation_provider $nav, request_interface $request, template $template, $phpbb_root_path, $php_ext)
|
||||
public function __construct(driver_interface $cache, container_factory $container, database $db_helper, helper $controller_helper, install_helper $install_helper, factory $iohandler, language $language, navigation_provider $nav, request_interface $request, template $template, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->installer_cache = $cache;
|
||||
$this->controller_helper = $controller_helper;
|
||||
$this->db_helper = $db_helper;
|
||||
$this->install_helper = $install_helper;
|
||||
@ -379,6 +387,7 @@ class convertor
|
||||
// If we reached this step (conversion completed) we want to purge the cache and log the user out.
|
||||
// This is for making sure the session get not screwed due to the 3.0.x users table being completely new.
|
||||
$this->cache->purge();
|
||||
$this->installer_cache->purge();
|
||||
|
||||
require_once($this->phpbb_root_path . 'includes/constants.' . $this->php_ext);
|
||||
require_once($this->phpbb_root_path . 'includes/functions_convert.' . $this->php_ext);
|
||||
|
@ -200,6 +200,7 @@ $lang = array_merge($lang, array(
|
||||
'INST_ERR_DB_NO_SQLITE3' => 'The version of the SQLite extension you have installed is too old, it must be upgraded to at least 3.6.15.',
|
||||
'INST_ERR_DB_NO_ORACLE' => 'The version of Oracle installed on this machine requires you to set the <var>NLS_CHARACTERSET</var> parameter to <var>UTF8</var>. Either upgrade your installation to 9.2+ or change the parameter.',
|
||||
'INST_ERR_DB_NO_POSTGRES' => 'The database you have selected was not created in <var>UNICODE</var> or <var>UTF8</var> encoding. Try installing with a database in <var>UNICODE</var> or <var>UTF8</var> encoding.',
|
||||
'INST_SCHEMA_FILE_NOT_WRITABLE' => 'The schema file is not writable',
|
||||
|
||||
//
|
||||
// Email data
|
||||
@ -277,7 +278,9 @@ $lang = array_merge($lang, array(
|
||||
// Install database
|
||||
'TASK_ADD_CONFIG_SETTINGS' => 'Adding configuration settings',
|
||||
'TASK_ADD_DEFAULT_DATA' => 'Adding default settings to the database',
|
||||
'TASK_CREATE_DATABASE_SCHEMA' => 'Creating database schema',
|
||||
'TASK_CREATE_DATABASE_SCHEMA_FILE' => 'Creating database schema file',
|
||||
'TASK_SETUP_DATABASE' => 'Setting up database',
|
||||
'TASK_CREATE_TABLES' => 'Creating tables',
|
||||
|
||||
// Install data
|
||||
'TASK_ADD_BOTS' => 'Registering bots',
|
||||
|
@ -95,8 +95,9 @@ class config
|
||||
$this->installer_config = array();
|
||||
$this->system_data = array();
|
||||
$this->progress_data = array(
|
||||
'last_task_module_name' => '', // Stores the service name of the latest finished module
|
||||
'last_task_name' => '', // Stores the service name of the latest finished task
|
||||
'last_task_module_neme' => '', // Stores the service name of the latest finished module
|
||||
'last_task_module_index' => 0, // Stores the index of the latest finished module
|
||||
'last_task_index' => 0, // Stores the index of the latest finished task
|
||||
'max_task_progress' => 0,
|
||||
'current_task_progress' => 0,
|
||||
'_restart_points' => array(),
|
||||
@ -187,21 +188,23 @@ class config
|
||||
/**
|
||||
* Saves the latest executed task
|
||||
*
|
||||
* @param string $task_service_name Name of the installer task service
|
||||
* @param int $task_service_index Index of the installer task service in the module
|
||||
*/
|
||||
public function set_finished_task($task_service_name)
|
||||
public function set_finished_task($task_service_index)
|
||||
{
|
||||
$this->progress_data['last_task_name'] = $task_service_name;
|
||||
$this->progress_data['last_task_index'] = $task_service_index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active module
|
||||
*
|
||||
* @param string $module_service_name Name of the installer module service
|
||||
* @param int $module_service_index Index of the installer module service
|
||||
*/
|
||||
public function set_active_module($module_service_name)
|
||||
public function set_active_module($module_service_name, $module_service_index)
|
||||
{
|
||||
$this->progress_data['last_task_module_name'] = $module_service_name;
|
||||
$this->progress_data['last_task_module_index'] = $module_service_index;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -391,6 +394,11 @@ class config
|
||||
*/
|
||||
public function set_finished_navigation_stage($nav_path)
|
||||
{
|
||||
if (isset($this->navigation_data['finished']) && in_array($nav_path, $this->navigation_data['finished']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->navigation_data['finished'][] = $nav_path;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace phpbb\install\helper;
|
||||
|
||||
use phpbb\cache\driver\dummy;
|
||||
use phpbb\install\exception\cannot_build_container_exception;
|
||||
use phpbb\language\language;
|
||||
use phpbb\request\request;
|
||||
@ -157,25 +156,20 @@ class container_factory
|
||||
->with_environment('production')
|
||||
->with_config($phpbb_config_php_file)
|
||||
->with_config_path($config_path)
|
||||
->without_cache()
|
||||
->without_compiled_container()
|
||||
->get_container();
|
||||
|
||||
// Setting request is required for the compatibility globals as those are generated from
|
||||
// this container
|
||||
$this->container->register('request')->setSynthetic(true);
|
||||
$this->container->set('request', $this->request);
|
||||
|
||||
$this->container->register('language')->setSynthetic(true);
|
||||
$this->container->set('language', $this->language);
|
||||
|
||||
// Replace cache service, as config gets cached, and we don't want that when we are installing
|
||||
if (!is_dir($other_config_path))
|
||||
if (!$this->container->isFrozen())
|
||||
{
|
||||
$this->container->register('cache.driver')->setSynthetic(true);
|
||||
$this->container->set('cache.driver', new dummy());
|
||||
$this->container->register('request')->setSynthetic(true);
|
||||
$this->container->register('language')->setSynthetic(true);
|
||||
}
|
||||
|
||||
$this->container->set('request', $this->request);
|
||||
$this->container->set('language', $this->language);
|
||||
|
||||
$this->container->compile();
|
||||
|
||||
$phpbb_container = $this->container;
|
||||
|
@ -209,9 +209,15 @@ class ajax_iohandler extends iohandler_base
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function send_response()
|
||||
public function send_response($no_more_output = false)
|
||||
{
|
||||
$json_data_array = $this->prepare_json_array();
|
||||
$json_data_array = $this->prepare_json_array($no_more_output);
|
||||
|
||||
if (empty($json_data_array))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$json_data = json_encode($json_data_array);
|
||||
|
||||
// Try to push content to the browser
|
||||
@ -223,23 +229,43 @@ class ajax_iohandler extends iohandler_base
|
||||
/**
|
||||
* Prepares iohandler's data to be sent out to the client.
|
||||
*
|
||||
* @param bool $no_more_output Whether or not there will be more output in this response
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function prepare_json_array()
|
||||
protected function prepare_json_array($no_more_output = false)
|
||||
{
|
||||
$json_array = array(
|
||||
'errors' => $this->errors,
|
||||
'warnings' => $this->warnings,
|
||||
'logs' => $this->logs,
|
||||
'success' => $this->success,
|
||||
'download' => $this->download,
|
||||
);
|
||||
$json_array = array();
|
||||
|
||||
if (!empty($this->errors))
|
||||
{
|
||||
$json_array['errors'] = $this->errors;
|
||||
$this->errors = array();
|
||||
}
|
||||
|
||||
if (!empty($this->warnings))
|
||||
{
|
||||
$json_array['warnings'] = $this->warnings;
|
||||
$this->warnings = array();
|
||||
}
|
||||
|
||||
if (!empty($this->logs))
|
||||
{
|
||||
$json_array['logs'] = $this->logs;
|
||||
$this->logs = array();
|
||||
}
|
||||
|
||||
if (!empty($this->success))
|
||||
{
|
||||
$json_array['success'] = $this->success;
|
||||
$this->success = array();
|
||||
}
|
||||
|
||||
if (!empty($this->download))
|
||||
{
|
||||
$json_array['download'] = $this->download;
|
||||
$this->download = array();
|
||||
}
|
||||
|
||||
if (!empty($this->form))
|
||||
{
|
||||
@ -293,6 +319,11 @@ class ajax_iohandler extends iohandler_base
|
||||
$this->redirect_url = array();
|
||||
}
|
||||
|
||||
if ($no_more_output)
|
||||
{
|
||||
$json_array['over'] = true;
|
||||
}
|
||||
|
||||
return $json_array;
|
||||
}
|
||||
|
||||
@ -398,7 +429,7 @@ class ajax_iohandler extends iohandler_base
|
||||
public function redirect($url, $use_ajax = false)
|
||||
{
|
||||
$this->redirect_url = array('url' => $url, 'use_ajax' => $use_ajax);
|
||||
$this->send_response();
|
||||
$this->send_response(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ class cli_iohandler extends iohandler_base
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function send_response()
|
||||
public function send_response($no_more_output = false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,10 @@ interface iohandler_interface
|
||||
{
|
||||
/**
|
||||
* Renders or returns response message
|
||||
*
|
||||
* @param bool $no_more_output Whether or not there will be more output in this output unit
|
||||
*/
|
||||
public function send_response();
|
||||
public function send_response($no_more_output = false);
|
||||
|
||||
/**
|
||||
* Returns input variable
|
||||
|
@ -15,11 +15,13 @@ namespace phpbb\install;
|
||||
|
||||
use phpbb\cache\driver\driver_interface;
|
||||
use phpbb\di\ordered_service_collection;
|
||||
use phpbb\install\exception\cannot_build_container_exception;
|
||||
use phpbb\install\exception\installer_config_not_writable_exception;
|
||||
use phpbb\install\exception\jump_to_restart_point_exception;
|
||||
use phpbb\install\exception\resource_limit_reached_exception;
|
||||
use phpbb\install\exception\user_interaction_required_exception;
|
||||
use phpbb\install\helper\config;
|
||||
use phpbb\install\helper\container_factory;
|
||||
use phpbb\install\helper\iohandler\cli_iohandler;
|
||||
use phpbb\install\helper\iohandler\iohandler_interface;
|
||||
use phpbb\path_helper;
|
||||
@ -31,13 +33,18 @@ class installer
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* @var container_factory
|
||||
*/
|
||||
protected $container_factory;
|
||||
|
||||
/**
|
||||
* @var config
|
||||
*/
|
||||
protected $install_config;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var ordered_service_collection
|
||||
*/
|
||||
protected $installer_modules;
|
||||
|
||||
@ -58,19 +65,27 @@ class installer
|
||||
*/
|
||||
protected $module_step_count;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $purge_cache_before;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param driver_interface $cache Cache service
|
||||
* @param config $config Installer config handler
|
||||
* @param path_helper $path_helper Path helper
|
||||
* @param container_factory $container Container
|
||||
*/
|
||||
public function __construct(driver_interface $cache, config $config, path_helper $path_helper)
|
||||
public function __construct(driver_interface $cache, config $config, path_helper $path_helper, container_factory $container)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->install_config = $config;
|
||||
$this->container_factory = $container;
|
||||
$this->installer_modules = null;
|
||||
$this->web_root = $path_helper->get_web_root_path();
|
||||
$this->purge_cache_before = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,6 +111,16 @@ class installer
|
||||
$this->iohandler = $iohandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to purge cache before the installation process
|
||||
*
|
||||
* @param bool $purge_cache_before
|
||||
*/
|
||||
public function set_purge_cache_before($purge_cache_before)
|
||||
{
|
||||
$this->purge_cache_before = $purge_cache_before;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run phpBB installer
|
||||
*/
|
||||
@ -104,9 +129,16 @@ class installer
|
||||
// Load install progress
|
||||
$this->install_config->load_config();
|
||||
|
||||
if (!$this->install_config->get('cache_purged_before', false) && $this->purge_cache_before)
|
||||
{
|
||||
/** @var \phpbb\cache\driver\driver_interface $cache */
|
||||
$cache = $this->container_factory->get('cache.driver');
|
||||
$cache->purge();
|
||||
$this->install_config->set('cache_purged_before', true);
|
||||
}
|
||||
|
||||
// Recover install progress
|
||||
$module_name = $this->recover_progress();
|
||||
$module_found = false;
|
||||
$module_index = $this->recover_progress();
|
||||
|
||||
// Variable used to check if the install process have been finished
|
||||
$install_finished = false;
|
||||
@ -141,29 +173,13 @@ class installer
|
||||
|
||||
try
|
||||
{
|
||||
foreach ($this->installer_modules as $name => $module)
|
||||
{
|
||||
// Skip forward until the current task is reached
|
||||
if (!$module_found)
|
||||
{
|
||||
if ($module_name === $name || empty($module_name))
|
||||
{
|
||||
$module_found = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$iterator = $this->installer_modules->getIterator();
|
||||
$iterator->seek($module_index);
|
||||
|
||||
// Log progress
|
||||
$this->install_config->set_active_module($name);
|
||||
|
||||
// Run until there are available resources
|
||||
if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)
|
||||
while ($iterator->valid())
|
||||
{
|
||||
throw new resource_limit_reached_exception();
|
||||
}
|
||||
$module = $iterator->current();
|
||||
$name = $iterator->key();
|
||||
|
||||
// Check if module should be executed
|
||||
if (!$module->is_essential() && !$module->check_requirements())
|
||||
@ -176,19 +192,33 @@ class installer
|
||||
$name,
|
||||
));
|
||||
$this->install_config->increment_current_task_progress($this->module_step_count[$name]);
|
||||
continue;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Set the correct stage in the navigation bar
|
||||
$this->install_config->set_active_navigation_stage($module->get_navigation_stage_path());
|
||||
$this->iohandler->set_active_stage_menu($module->get_navigation_stage_path());
|
||||
|
||||
$this->iohandler->send_response();
|
||||
|
||||
$module->run();
|
||||
|
||||
$this->install_config->set_finished_navigation_stage($module->get_navigation_stage_path());
|
||||
$this->iohandler->set_finished_stage_menu($module->get_navigation_stage_path());
|
||||
}
|
||||
|
||||
$module_index++;
|
||||
$iterator->next();
|
||||
|
||||
// Save progress
|
||||
$this->install_config->set_active_module($name, $module_index);
|
||||
|
||||
if ($iterator->valid() && ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0))
|
||||
{
|
||||
throw new resource_limit_reached_exception();
|
||||
}
|
||||
}
|
||||
|
||||
// Installation finished
|
||||
$install_finished = true;
|
||||
|
||||
@ -208,7 +238,7 @@ class installer
|
||||
}
|
||||
catch (user_interaction_required_exception $e)
|
||||
{
|
||||
// Do nothing
|
||||
$this->iohandler->send_response(true);
|
||||
}
|
||||
catch (resource_limit_reached_exception $e)
|
||||
{
|
||||
@ -222,7 +252,7 @@ class installer
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$this->iohandler->add_error_message($e->getMessage());
|
||||
$this->iohandler->send_response();
|
||||
$this->iohandler->send_response(true);
|
||||
$fail_cleanup = true;
|
||||
}
|
||||
|
||||
@ -230,11 +260,12 @@ class installer
|
||||
{
|
||||
// Send install finished message
|
||||
$this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count());
|
||||
$this->iohandler->send_response(true);
|
||||
}
|
||||
else if ($send_refresh)
|
||||
{
|
||||
$this->iohandler->request_refresh();
|
||||
$this->iohandler->send_response();
|
||||
$this->iohandler->send_response(true);
|
||||
}
|
||||
|
||||
// Save install progress
|
||||
@ -244,6 +275,17 @@ class installer
|
||||
{
|
||||
$this->install_config->clean_up_config_file();
|
||||
$this->cache->purge();
|
||||
|
||||
try
|
||||
{
|
||||
/** @var \phpbb\cache\driver\driver_interface $cache */
|
||||
$cache = $this->container_factory->get('cache.driver');
|
||||
$cache->purge();
|
||||
}
|
||||
catch (cannot_build_container_exception $e)
|
||||
{
|
||||
// Do not do anything, this is just means there is no config.php yet
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -270,6 +312,6 @@ class installer
|
||||
protected function recover_progress()
|
||||
{
|
||||
$progress_array = $this->install_config->get_progress_data();
|
||||
return $progress_array['last_task_module_name'];
|
||||
return $progress_array['last_task_module_index'];
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,6 @@ class create_config_file extends \phpbb\install\task_base
|
||||
else
|
||||
{
|
||||
$this->iohandler->add_error_message('UNABLE_TO_WRITE_CONFIG_FILE');
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
|
||||
@ -139,7 +138,6 @@ class create_config_file extends \phpbb\install\task_base
|
||||
{
|
||||
// We were unable to create the lock file - abort
|
||||
$this->iohandler->add_error_message('UNABLE_TO_WRITE_LOCK');
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
@fclose($fp);
|
||||
|
@ -136,7 +136,6 @@ class obtain_admin_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||
$this->io_handler->add_user_form_group('ADMIN_CONFIG', $admin_form);
|
||||
|
||||
// Require user interaction
|
||||
$this->io_handler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,6 @@ class obtain_board_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||
|
||||
$this->io_handler->add_user_form_group('BOARD_CONFIG', $board_form);
|
||||
|
||||
$this->io_handler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,6 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in
|
||||
$this->io_handler->add_user_form_group('DB_CONFIG', $database_form);
|
||||
|
||||
// Require user interaction
|
||||
$this->io_handler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,6 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||
|
||||
$this->io_handler->add_user_form_group('EMAIL_CONFIG', $email_form);
|
||||
|
||||
$this->io_handler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,6 @@ class obtain_file_updater_method extends task_base
|
||||
),
|
||||
));
|
||||
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +180,6 @@ class obtain_server_data extends \phpbb\install\task_base implements \phpbb\inst
|
||||
|
||||
$this->io_handler->add_user_form_group('SERVER_CONFIG', $server_form);
|
||||
|
||||
$this->io_handler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,6 @@ class obtain_update_ftp_data extends task_base
|
||||
),
|
||||
));
|
||||
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,6 @@ class obtain_update_settings extends task_base
|
||||
),
|
||||
));
|
||||
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace phpbb\install\module\requirements;
|
||||
|
||||
use phpbb\install\exception\resource_limit_reached_exception;
|
||||
use phpbb\install\exception\user_interaction_required_exception;
|
||||
use phpbb\install\module_base;
|
||||
|
||||
@ -25,41 +24,8 @@ abstract class abstract_requirements_module extends module_base
|
||||
public function run()
|
||||
{
|
||||
$tests_passed = true;
|
||||
|
||||
// Recover install progress
|
||||
$task_name = $this->recover_progress();
|
||||
$task_found = false;
|
||||
|
||||
/**
|
||||
* @var string $name ID of the service
|
||||
* @var \phpbb\install\task_interface $task Task object
|
||||
*/
|
||||
foreach ($this->task_collection as $name => $task)
|
||||
{
|
||||
// Run until there are available resources
|
||||
if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)
|
||||
{
|
||||
throw new resource_limit_reached_exception();
|
||||
}
|
||||
|
||||
// Skip forward until the next task is reached
|
||||
if (!$task_found)
|
||||
{
|
||||
if ($name === $task_name || empty($task_name))
|
||||
{
|
||||
$task_found = true;
|
||||
|
||||
if ($name === $task_name)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we can run the task
|
||||
if (!$task->is_essential() && !$task->check_requirements())
|
||||
{
|
||||
@ -76,7 +42,7 @@ abstract class abstract_requirements_module extends module_base
|
||||
}
|
||||
|
||||
// Module finished, so clear task progress
|
||||
$this->install_config->set_finished_task('');
|
||||
$this->install_config->set_finished_task(0);
|
||||
|
||||
// Check if tests have failed
|
||||
if (!$tests_passed)
|
||||
@ -91,7 +57,6 @@ abstract class abstract_requirements_module extends module_base
|
||||
));
|
||||
|
||||
// Send the response and quit
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,6 @@ class update extends task_base
|
||||
array_unshift($msg, $e->getMessage());
|
||||
|
||||
$this->iohandler->add_error_message($msg);
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,6 @@ class download_updated_files extends task_base
|
||||
),
|
||||
));
|
||||
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,6 @@ class show_file_status extends task_base
|
||||
));
|
||||
|
||||
// Show results to the user
|
||||
$this->iohandler->send_response();
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
else
|
||||
|
@ -105,47 +105,23 @@ abstract class module_base implements module_interface
|
||||
public function run()
|
||||
{
|
||||
// Recover install progress
|
||||
$task_name = $this->recover_progress();
|
||||
$task_found = false;
|
||||
$task_index = $this->recover_progress();
|
||||
$iterator = $this->task_collection->getIterator();
|
||||
|
||||
/**
|
||||
* @var string $name ID of the service
|
||||
* @var \phpbb\install\task_interface $task Task object
|
||||
*/
|
||||
foreach ($this->task_collection as $name => $task)
|
||||
if ($task_index < $iterator->count())
|
||||
{
|
||||
// Run until there are available resources
|
||||
if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)
|
||||
{
|
||||
throw new resource_limit_reached_exception();
|
||||
}
|
||||
|
||||
// Skip forward until the next task is reached
|
||||
if (!$task_found)
|
||||
{
|
||||
if ($name === $task_name || empty($task_name))
|
||||
{
|
||||
$task_found = true;
|
||||
|
||||
if ($name === $task_name)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$iterator->seek($task_index);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$this->install_config->set_finished_task(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Send progress information
|
||||
if ($this->allow_progress_bar)
|
||||
while ($iterator->valid())
|
||||
{
|
||||
$this->iohandler->set_progress(
|
||||
$task->get_task_lang_name(),
|
||||
$this->install_config->get_current_task_progress()
|
||||
);
|
||||
}
|
||||
$task = $iterator->current();
|
||||
$name = $iterator->key();
|
||||
|
||||
// Check if we can run the task
|
||||
if (!$task->is_essential() && !$task->check_requirements())
|
||||
@ -156,8 +132,21 @@ abstract class module_base implements module_interface
|
||||
));
|
||||
|
||||
$this->install_config->increment_current_task_progress($this->task_step_count[$name]);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send progress information
|
||||
if ($this->allow_progress_bar)
|
||||
{
|
||||
$this->iohandler->set_progress(
|
||||
$task->get_task_lang_name(),
|
||||
$this->install_config->get_current_task_progress()
|
||||
);
|
||||
|
||||
$this->iohandler->send_response();
|
||||
}
|
||||
|
||||
$task->run();
|
||||
|
||||
if ($this->allow_progress_bar)
|
||||
{
|
||||
@ -165,11 +154,11 @@ abstract class module_base implements module_interface
|
||||
// then that should be incremented in the task itself
|
||||
$this->install_config->increment_current_task_progress();
|
||||
}
|
||||
}
|
||||
|
||||
$task->run();
|
||||
|
||||
// Log install progress
|
||||
$this->install_config->set_finished_task($name);
|
||||
$task_index++;
|
||||
$this->install_config->set_finished_task($task_index);
|
||||
$iterator->next();
|
||||
|
||||
// Send progress information
|
||||
if ($this->allow_progress_bar)
|
||||
@ -181,10 +170,16 @@ abstract class module_base implements module_interface
|
||||
}
|
||||
|
||||
$this->iohandler->send_response();
|
||||
|
||||
// Run until there are available resources
|
||||
if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0)
|
||||
{
|
||||
throw new resource_limit_reached_exception();
|
||||
}
|
||||
}
|
||||
|
||||
// Module finished, so clear task progress
|
||||
$this->install_config->set_finished_task('');
|
||||
$this->install_config->set_finished_task(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,7 +190,7 @@ abstract class module_base implements module_interface
|
||||
protected function recover_progress()
|
||||
{
|
||||
$progress_array = $this->install_config->get_progress_data();
|
||||
return $progress_array['last_task_name'];
|
||||
return $progress_array['last_task_index'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,8 +52,8 @@ class phpbb_installer_config_test extends phpbb_test_case
|
||||
|
||||
public function test_progress_tracking()
|
||||
{
|
||||
$this->config->set_finished_task('foo');
|
||||
$this->config->set_active_module('bar');
|
||||
$this->config->set_finished_task(0);
|
||||
$this->config->set_active_module('bar', 5);
|
||||
$this->config->set_task_progress_count(10);
|
||||
$this->config->increment_current_task_progress();
|
||||
|
||||
@ -66,7 +66,8 @@ class phpbb_installer_config_test extends phpbb_test_case
|
||||
$result = $this->config->get_progress_data();
|
||||
$expected_result = array(
|
||||
'last_task_module_name' => 'bar',
|
||||
'last_task_name' => 'foo',
|
||||
'last_task_module_index' => 5,
|
||||
'last_task_index' => 0,
|
||||
'max_task_progress' => 10,
|
||||
'current_task_progress' => 3,
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user