diff options
author | Tristan Darricau <github@nicofuma.fr> | 2014-10-14 17:58:29 +0200 |
---|---|---|
committer | Tristan Darricau <github@nicofuma.fr> | 2014-10-14 17:58:29 +0200 |
commit | 56d7c2c6ed3e5924aeced53a163bfd1aa8288034 (patch) | |
tree | 15848d0cdb881a9b30793941cdeae0fed6f58141 /phpBB/phpbb/console/command/db | |
parent | 29b54d12ccece3ad0120089c17b0886e3b77f3d1 (diff) | |
download | forums-56d7c2c6ed3e5924aeced53a163bfd1aa8288034.tar forums-56d7c2c6ed3e5924aeced53a163bfd1aa8288034.tar.gz forums-56d7c2c6ed3e5924aeced53a163bfd1aa8288034.tar.bz2 forums-56d7c2c6ed3e5924aeced53a163bfd1aa8288034.tar.xz forums-56d7c2c6ed3e5924aeced53a163bfd1aa8288034.zip |
[ticket/13126] Improve the feedback when running the migrations
PHPBB3-13126
Diffstat (limited to 'phpBB/phpbb/console/command/db')
-rw-r--r-- | phpBB/phpbb/console/command/db/migrate.php | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index c760cde5b5..ecb84d7401 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -53,6 +53,30 @@ class migrate extends \phpbb\console\command\command protected function execute(InputInterface $input, OutputInterface $output) { + $user = $this->user; + $this->migrator->set_output_handler( + new \phpbb\db\migrator_output_handler( + function($message, $verbosity) use ($output, $user) + { + if ($verbosity <= $output->getVerbosity()) + { + $final_message = call_user_func_array(array($user, 'lang'), $message); + + if ($verbosity === \phpbb\db\migrator_output_handler::VERBOSITY_NORMAL) + { + $final_message = '<info>' . $final_message . '</info>'; + } + else if ($verbosity === \phpbb\db\migrator_output_handler::VERBOSITY_VERY_VERBOSE) + { + $final_message = '<comment>' . $final_message . '</comment>'; + } + + $output->writeln($final_message); + } + } + ) + ); + $this->migrator->create_migrations_table(); $this->cache->purge(); @@ -61,8 +85,6 @@ class migrate extends \phpbb\console\command\command $orig_version = $this->config['version']; while (!$this->migrator->finished()) { - $migration_start_time = microtime(true); - try { $this->migrator->update(); @@ -73,36 +95,6 @@ class migrate extends \phpbb\console\command\command $this->finalise_update(); return 1; } - - $migration_stop_time = microtime(true) - $migration_start_time; - - $state = array_merge( - array( - 'migration_schema_done' => false, - 'migration_data_done' => false, - ), - $this->migrator->last_run_migration['state'] - ); - - if (!empty($this->migrator->last_run_migration['effectively_installed'])) - { - $msg = $this->user->lang('MIGRATION_EFFECTIVELY_INSTALLED', $this->migrator->last_run_migration['name']); - $output->writeln("<comment>$msg</comment>"); - } - else if ($this->migrator->last_run_migration['task'] == 'process_data_step' && $state['migration_data_done']) - { - $msg = $this->user->lang('MIGRATION_DATA_DONE', $this->migrator->last_run_migration['name'], $migration_stop_time); - $output->writeln("<info>$msg</info>"); - } - else if ($this->migrator->last_run_migration['task'] == 'process_data_step') - { - $output->writeln($this->user->lang('MIGRATION_DATA_IN_PROGRESS', $this->migrator->last_run_migration['name'], $migration_stop_time)); - } - else if ($state['migration_schema_done']) - { - $msg = $this->user->lang('MIGRATION_SCHEMA_DONE', $this->migrator->last_run_migration['name'], $migration_stop_time); - $output->writeln("<info>$msg</info>"); - } } if ($orig_version != $this->config['version']) |