mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-11 22:08:54 +00:00
[ticket/14742] Fix progress bar in database updater
Because of the new way, schema update steps are handled, the already misleading progress bar was even more misleading. This should fix it. PHPBB3-14742
This commit is contained in:
parent
210310b584
commit
03be89ebd7
2 changed files with 38 additions and 3 deletions
|
@ -204,6 +204,28 @@ class migrator
|
|||
return $this->migrations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of available and not installed migration class names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_installable_migrations()
|
||||
{
|
||||
$unfinished_migrations = array();
|
||||
|
||||
foreach ($this->migrations as $name)
|
||||
{
|
||||
if (!isset($this->migration_state[$name]) ||
|
||||
!$this->migration_state[$name]['migration_schema_done'] ||
|
||||
!$this->migration_state[$name]['migration_data_done'])
|
||||
{
|
||||
$unfinished_migrations[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
return $unfinished_migrations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a single update step from the next migration to be applied.
|
||||
*
|
||||
|
|
|
@ -140,7 +140,14 @@ class update extends task_base
|
|||
->get_classes();
|
||||
|
||||
$this->migrator->set_migrations($migrations);
|
||||
$migration_count = count($this->migrator->get_migrations());
|
||||
|
||||
$migration_count = $this->installer_config->get('database_update_migrations', -1);
|
||||
if ($migration_count < 0)
|
||||
{
|
||||
$migration_count = count($this->migrator->get_installable_migrations());
|
||||
$this->installer_config->set('database_update_migrations', $migration_count);
|
||||
}
|
||||
|
||||
$this->iohandler->set_task_count($migration_count, true);
|
||||
$this->installer_config->set_task_progress_count($migration_count);
|
||||
$progress_count = $this->installer_config->get('database_update_count', 0);
|
||||
|
@ -150,8 +157,14 @@ class update extends task_base
|
|||
try
|
||||
{
|
||||
$this->migrator->update();
|
||||
$progress_count++;
|
||||
$this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count);
|
||||
|
||||
$last_run_migration = $this->migrator->get_last_run_migration();
|
||||
|
||||
if ($last_run_migration['state']['migration_data_done'])
|
||||
{
|
||||
$progress_count++;
|
||||
$this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count);
|
||||
}
|
||||
}
|
||||
catch (exception $e)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue