mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/14742] Increase user feedback by improving progress bar
We now count and display each step that was done by increasing the task count. PHPBB3-14742
This commit is contained in:
parent
88384a1e63
commit
a37f10ae09
2 changed files with 21 additions and 6 deletions
|
@ -198,6 +198,16 @@ class cli_iohandler extends iohandler_base
|
||||||
|
|
||||||
if ($this->output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL)
|
if ($this->output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL)
|
||||||
{
|
{
|
||||||
|
if ($this->progress_bar !== null)
|
||||||
|
{
|
||||||
|
// Symfony's ProgressBar is immutable regarding task_count, so delete the old and create a new one.
|
||||||
|
$this->progress_bar->clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->io->newLine(2);
|
||||||
|
}
|
||||||
|
|
||||||
$this->progress_bar = $this->io->createProgressBar($task_count);
|
$this->progress_bar = $this->io->createProgressBar($task_count);
|
||||||
$this->progress_bar->setFormat(
|
$this->progress_bar->setFormat(
|
||||||
" %current:3s%/%max:-3s% %bar% %percent:3s%%\n" .
|
" %current:3s%/%max:-3s% %bar% %percent:3s%%\n" .
|
||||||
|
@ -212,7 +222,6 @@ class cli_iohandler extends iohandler_base
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->progress_bar->setMessage('');
|
$this->progress_bar->setMessage('');
|
||||||
$this->io->newLine(2);
|
|
||||||
$this->progress_bar->start();
|
$this->progress_bar->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,18 +158,23 @@ class update extends task_base
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$this->migrator->update();
|
$this->migrator->update();
|
||||||
|
$progress_count++;
|
||||||
|
|
||||||
$last_run_migration = $this->migrator->get_last_run_migration();
|
$last_run_migration = $this->migrator->get_last_run_migration();
|
||||||
if (isset($last_run_migration['effectively_installed']) && $last_run_migration['effectively_installed'])
|
if (isset($last_run_migration['effectively_installed']) && $last_run_migration['effectively_installed'])
|
||||||
{
|
{
|
||||||
$progress_count += 2;
|
// We skipped two step, so increment $progress_count by another one
|
||||||
}
|
|
||||||
else if (($last_run_migration['task'] === 'process_schema_step' && $last_run_migration['state']['migration_schema_done']) ||
|
|
||||||
($last_run_migration['task'] === 'process_data_step' && $last_run_migration['state']['migration_data_done']))
|
|
||||||
{
|
|
||||||
$progress_count++;
|
$progress_count++;
|
||||||
}
|
}
|
||||||
|
else if (($last_run_migration['task'] === 'process_schema_step' && !$last_run_migration['state']['migration_schema_done']) ||
|
||||||
|
($last_run_migration['task'] === 'process_data_step' && !$last_run_migration['state']['migration_data_done']))
|
||||||
|
{
|
||||||
|
// We just run a step that wasn't counted yet so make it count
|
||||||
|
$migration_step_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->iohandler->set_task_count($migration_step_count);
|
||||||
|
$this->installer_config->set_task_progress_count($migration_step_count);
|
||||||
$this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count);
|
$this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count);
|
||||||
}
|
}
|
||||||
catch (exception $e)
|
catch (exception $e)
|
||||||
|
@ -184,6 +189,7 @@ class update extends task_base
|
||||||
if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0)
|
if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0)
|
||||||
{
|
{
|
||||||
$this->installer_config->set('database_update_count', $progress_count);
|
$this->installer_config->set('database_update_count', $progress_count);
|
||||||
|
$this->installer_config->set('database_update_migration_steps', $migration_step_count);
|
||||||
throw new resource_limit_reached_exception();
|
throw new resource_limit_reached_exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue