mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-04 13:35:13 +02:00
[ticket/13740] Add backend support for install progress tracking
PHPBB3-13740
This commit is contained in:
parent
4df89d8848
commit
37b0134aa4
@ -85,8 +85,14 @@ class install
|
||||
$this->iohandler_factory->set_environment('nojs');
|
||||
}
|
||||
|
||||
// Set the appropriate input-output handler
|
||||
//$this->installer->set_iohandler($this->iohandler_factory->get());
|
||||
|
||||
if ($this->request->is_ajax())
|
||||
{
|
||||
// @todo: remove this line, and use the above
|
||||
$this->installer->set_iohandler($this->iohandler_factory->get());
|
||||
|
||||
$installer = $this->installer;
|
||||
$response = new StreamedResponse();
|
||||
$response->setCallback(function() use ($installer) {
|
||||
|
@ -81,6 +81,8 @@ class config
|
||||
'last_task_module_name' => '', // Stores the service name of the latest finished module
|
||||
'last_task_index' => 0,
|
||||
'last_task_name' => '', // Stores the service name of the latest finished task
|
||||
'max_task_progress' => 0,
|
||||
'current_task_progress' => 0,
|
||||
);
|
||||
|
||||
$this->install_config_file = $this->phpbb_root_path . 'store/install_config.php';
|
||||
@ -108,8 +110,6 @@ class config
|
||||
*
|
||||
* @param string $param_name Name of the parameter
|
||||
* @param mixed $value Values to set the parameter
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function set($param_name, $value)
|
||||
{
|
||||
@ -161,8 +161,6 @@ class config
|
||||
*
|
||||
* @param string $task_service_name Name of the installer task service
|
||||
* @param int $task_index Index of the task in the task list array
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function set_finished_task($task_service_name, $task_index)
|
||||
{
|
||||
@ -175,8 +173,6 @@ class config
|
||||
*
|
||||
* @param string $module_service_name Name of the installer module service
|
||||
* @param int $module_index Index of the module in the module list array
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function set_active_module($module_service_name, $module_index)
|
||||
{
|
||||
@ -196,8 +192,6 @@ class config
|
||||
|
||||
/**
|
||||
* Recovers install configuration from file
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function load_config()
|
||||
{
|
||||
@ -216,8 +210,6 @@ class config
|
||||
|
||||
/**
|
||||
* Dumps install configuration to disk
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function save_config()
|
||||
{
|
||||
@ -239,9 +231,55 @@ class config
|
||||
}
|
||||
|
||||
/**
|
||||
* Filling up system_data array
|
||||
* Increments the task progress
|
||||
*/
|
||||
public function increment_current_task_progress()
|
||||
{
|
||||
$this->progress_data['current_task_progress']++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the task progress to a specific number
|
||||
*
|
||||
* @return null
|
||||
* @param int $task_progress The task progress number to be set
|
||||
*/
|
||||
public function set_current_task_progress($task_progress)
|
||||
{
|
||||
$this->progress_data['current_task_progress'] = $task_progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of tasks belonging to the installer in the current mode.
|
||||
*
|
||||
* @param int $task_progress_count Number of tasks
|
||||
*/
|
||||
public function set_task_progress_count($task_progress_count)
|
||||
{
|
||||
$this->progress_data['max_task_progress'] = $task_progress_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of the current task being executed
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_current_task_progress()
|
||||
{
|
||||
return $this->progress_data['current_task_progress'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of tasks belonging to the installer in the current mode.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_task_progress_count()
|
||||
{
|
||||
return $this->progress_data['max_task_progress'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Filling up system_data array
|
||||
*/
|
||||
protected function setup_system_data()
|
||||
{
|
||||
|
@ -48,6 +48,21 @@ abstract class iohandler_base implements iohandler_interface
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $task_progress_count;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $current_task_progress;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $current_task_name;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@ -56,6 +71,10 @@ abstract class iohandler_base implements iohandler_interface
|
||||
$this->errors = array();
|
||||
$this->warnings = array();
|
||||
$this->logs = array();
|
||||
|
||||
$this->task_progress_count = 0;
|
||||
$this->current_task_progress = 0;
|
||||
$this->current_task_name = '';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,6 +111,26 @@ abstract class iohandler_base implements iohandler_interface
|
||||
$this->logs[] = $this->translate_message($log_title, $log_description);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set_task_count($task_count)
|
||||
{
|
||||
$this->task_progress_count = $task_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set_progress($task_lang_key, $task_number)
|
||||
{
|
||||
if (!empty($task_lang_key))
|
||||
{
|
||||
$this->current_task_name = $this->language->lang($task_lang_key);
|
||||
$this->current_task_progress = $task_number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Localize message.
|
||||
*
|
||||
|
@ -30,6 +30,11 @@ class installer
|
||||
*/
|
||||
protected $installer_modules;
|
||||
|
||||
/**
|
||||
* @var \phpbb\install\helper\iohandler\iohandler_interface
|
||||
*/
|
||||
protected $iohandler;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -58,6 +63,16 @@ class installer
|
||||
$this->installer_modules = $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets input-output handler objects
|
||||
*
|
||||
* @param helper\iohandler\iohandler_interface $iohandler
|
||||
*/
|
||||
public function set_iohandler(\phpbb\install\helper\iohandler\iohandler_interface $iohandler)
|
||||
{
|
||||
$this->iohandler = $iohandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run phpBB installer
|
||||
*/
|
||||
@ -69,6 +84,20 @@ class installer
|
||||
// Recover install progress
|
||||
$module_index = $this->recover_progress();
|
||||
|
||||
// Count all tasks in the current installer modules
|
||||
$task_count = 0;
|
||||
foreach ($this->installer_modules as $name)
|
||||
{
|
||||
/** @var \phpbb\install\module_interface $module */
|
||||
$module = $this->container->get($name);
|
||||
|
||||
$task_count += $module->get_task_count();
|
||||
}
|
||||
|
||||
// Set task count
|
||||
$this->install_config->set_task_progress_count($task_count);
|
||||
$this->iohandler->set_task_count($task_count);
|
||||
|
||||
$install_finished = false;
|
||||
|
||||
try
|
||||
@ -107,11 +136,12 @@ class installer
|
||||
|
||||
if ($install_finished)
|
||||
{
|
||||
die ("install finished");
|
||||
// Send install finished message
|
||||
$this->iohandler->set_progress('INSTALLER_FINISHED', $this->install_config->get_task_progress_count());
|
||||
}
|
||||
else
|
||||
{
|
||||
die ("install memory or time limit reached");
|
||||
// @todo: Send refresh request
|
||||
}
|
||||
}
|
||||
catch (\phpbb\install\exception\user_interaction_required_exception $e)
|
||||
|
@ -221,4 +221,12 @@ class add_bots extends \phpbb\install\task_base
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return 'TASK_ADD_BOTS';
|
||||
}
|
||||
}
|
||||
|
@ -102,4 +102,12 @@ class add_languages extends \phpbb\install\task_base
|
||||
|
||||
$insert_buffer->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return 'TASK_ADD_LANGUAGES';
|
||||
}
|
||||
}
|
||||
|
@ -449,4 +449,12 @@ class add_modules extends \phpbb\install\task_base
|
||||
$this->module_manager->remove_cache_file($module_class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return 'TASK_ADD_MODULES';
|
||||
}
|
||||
}
|
||||
|
@ -322,4 +322,12 @@ class add_config_settings extends \phpbb\install\task_base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return 'TASK_ADD_CONFIG_SETTINGS';
|
||||
}
|
||||
}
|
||||
|
@ -142,4 +142,12 @@ class add_default_data extends \phpbb\install\task_base
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return 'TASK_ADD_DEFAULT_DATA';
|
||||
}
|
||||
}
|
||||
|
@ -195,4 +195,12 @@ class create_schema extends \phpbb\install\task_base
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return 'TASK_CREATE_DATABASE_SCHEMA';
|
||||
}
|
||||
}
|
||||
|
@ -216,4 +216,12 @@ class create_config_file extends \phpbb\install\task_base
|
||||
|
||||
return $config_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return 'TASK_CREATE_CONFIG_FILE';
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class notify_user extends \phpbb\install\task_base
|
||||
$messenger->anti_abuse_headers($this->config, $this->user);
|
||||
$messenger->assign_vars(array(
|
||||
'USERNAME' => htmlspecialchars_decode($this->install_config->get('admin_name')),
|
||||
'PASSWORD' => htmlspecialchars_decode($this->install_config->get('admin_pass1')))
|
||||
'PASSWORD' => htmlspecialchars_decode($this->install_config->get('admin_passwd')))
|
||||
);
|
||||
$messenger->send(NOTIFY_EMAIL);
|
||||
}
|
||||
@ -110,4 +110,12 @@ class notify_user extends \phpbb\install\task_base
|
||||
|
||||
@unlink($this->phpbb_root_path . 'cache/install_lock');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return 'TASK_NOTIFY_USER';
|
||||
}
|
||||
}
|
||||
|
@ -51,4 +51,12 @@ class populate_migrations extends \phpbb\install\task_base
|
||||
->get_classes();
|
||||
$this->migrator->populate_migrations($migrations);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return 'TASK_POPULATE_MIGRATIONS';
|
||||
}
|
||||
}
|
||||
|
@ -200,4 +200,12 @@ class obtain_admin_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||
|
||||
return $data_valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -167,4 +167,12 @@ class obtain_board_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||
$this->io_handler->send_response();
|
||||
throw new user_interaction_required_exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -252,4 +252,12 @@ class obtain_database_data extends \phpbb\install\task_base implements \phpbb\in
|
||||
|
||||
return $data_valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -148,4 +148,12 @@ class obtain_email_data extends \phpbb\install\task_base implements \phpbb\insta
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -70,4 +70,12 @@ class obtain_imagick_path extends \phpbb\install\task_base implements \phpbb\ins
|
||||
|
||||
$this->config->set('img_imagick', $img_imagick);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -184,4 +184,12 @@ class obtain_server_data extends \phpbb\install\task_base implements \phpbb\inst
|
||||
throw new user_interaction_required_exception();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -254,4 +254,12 @@ class check_filesystem extends \phpbb\install\task_base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -171,4 +171,12 @@ class check_server_environment extends \phpbb\install\task_base
|
||||
|
||||
$this->set_test_passed(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -110,8 +110,15 @@ abstract class module_base implements module_interface
|
||||
/** @var \phpbb\install\task_interface $task */
|
||||
$task = $this->container->get($this->task_collection[$task_index]);
|
||||
|
||||
// Send progress information
|
||||
$this->iohandler->set_progress(
|
||||
$task->get_task_lang_name(),
|
||||
$this->install_config->get_current_task_progress()
|
||||
);
|
||||
|
||||
// Iterate to the next task
|
||||
$task_index++;
|
||||
$this->install_config->increment_current_task_progress();
|
||||
|
||||
// Check if we can run the task
|
||||
if (!$task->is_essential() && !$task->check_requirements())
|
||||
@ -121,11 +128,11 @@ abstract class module_base implements module_interface
|
||||
|
||||
$task->run();
|
||||
|
||||
// Increment progress
|
||||
if ($this->get_task_count() !== 0)
|
||||
{
|
||||
//$this->iohandler->increment_progress();
|
||||
}
|
||||
// Send progress info
|
||||
$this->iohandler->set_progress(
|
||||
$task->get_task_lang_name(),
|
||||
$this->install_config->get_current_task_progress()
|
||||
);
|
||||
|
||||
$this->iohandler->send_response();
|
||||
|
||||
|
@ -40,8 +40,13 @@ interface task_interface
|
||||
|
||||
/**
|
||||
* Executes the task
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function run();
|
||||
|
||||
/**
|
||||
* Returns the language key of the name of the task
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_task_lang_name();
|
||||
}
|
||||
|
@ -226,3 +226,26 @@ $lang = array_merge($lang, array(
|
||||
'MENU_LICENSE' => 'License',
|
||||
'MENU_SUPPORT' => 'Support',
|
||||
));
|
||||
|
||||
// Task names
|
||||
$lang = array_merge($lang, array(
|
||||
// Install filesystem
|
||||
'TASK_CREATE_CONFIG_FILE' => 'Creating configuration file',
|
||||
|
||||
// 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',
|
||||
|
||||
// Install data
|
||||
'TASK_ADD_BOTS' => 'Registering bots',
|
||||
'TASK_ADD_LANGUAGES' => 'Installing available languages',
|
||||
'TASK_ADD_MODULES' => 'Installing modules',
|
||||
|
||||
// Install finish tasks
|
||||
'TASK_NOTIFY_USER' => 'Sending notification e-mail',
|
||||
'TASK_POPULATE_MIGRATIONS' => 'Populating migrations',
|
||||
|
||||
// Installer general progress messages
|
||||
'INSTALLER_FINISHED' => 'The installer has finished successfully',
|
||||
));
|
||||
|
Loading…
x
Reference in New Issue
Block a user