aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/console/command/db
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2014-10-25 12:04:29 -0700
committerNils Adermann <naderman@naderman.de>2014-10-25 12:04:29 -0700
commit6308a442d1b6ff61bd61b48e9628cae2884f7785 (patch)
tree8b9d31a37a896cffcaa224e5b387ae186870d9f0 /phpBB/phpbb/console/command/db
parentd2e31984075009f45d8822ef4ca2ec59422fba65 (diff)
parent078e0c1e440f7f906b670348e8da00141e245876 (diff)
downloadforums-6308a442d1b6ff61bd61b48e9628cae2884f7785.tar
forums-6308a442d1b6ff61bd61b48e9628cae2884f7785.tar.gz
forums-6308a442d1b6ff61bd61b48e9628cae2884f7785.tar.bz2
forums-6308a442d1b6ff61bd61b48e9628cae2884f7785.tar.xz
forums-6308a442d1b6ff61bd61b48e9628cae2884f7785.zip
Merge pull request #3060 from marc1706/ticket/13211
[ticket/13211] Add log wrapper for writing database updater to log file
Diffstat (limited to 'phpBB/phpbb/console/command/db')
-rw-r--r--phpBB/phpbb/console/command/db/console_migrator_output_handler.php69
-rw-r--r--phpBB/phpbb/console/command/db/migrate.php40
2 files changed, 76 insertions, 33 deletions
diff --git a/phpBB/phpbb/console/command/db/console_migrator_output_handler.php b/phpBB/phpbb/console/command/db/console_migrator_output_handler.php
new file mode 100644
index 0000000000..b9741a3838
--- /dev/null
+++ b/phpBB/phpbb/console/command/db/console_migrator_output_handler.php
@@ -0,0 +1,69 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\console\command\db;
+
+use phpbb\user;
+use phpbb\db\migrator_output_handler_interface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class console_migrator_output_handler implements migrator_output_handler_interface
+{
+ /**
+ * User object.
+ *
+ * @var user
+ */
+ private $user;
+
+ /**
+ * Console output object.
+ *
+ * @var OutputInterface
+ */
+ private $output;
+
+ /**
+ * Constructor
+ *
+ * @param user $user User object
+ * @param OutputInterface $output Console output object
+ */
+ public function __construct(user $user, OutputInterface $output)
+ {
+ $this->user = $user;
+ $this->output = $output;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function write($message, $verbosity)
+ {
+ if ($verbosity <= $this->output->getVerbosity())
+ {
+ $translated_message = call_user_func_array(array($this->user, 'lang'), $message);
+
+ if ($verbosity === migrator_output_handler_interface::VERBOSITY_NORMAL)
+ {
+ $translated_message = '<info>' . $translated_message . '</info>';
+ }
+ else if ($verbosity === migrator_output_handler_interface::VERBOSITY_VERBOSE)
+ {
+ $translated_message = '<comment>' . $translated_message . '</comment>';
+ }
+
+ $this->output->writeln($translated_message);
+ }
+ }
+}
diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php
index c760cde5b5..87c2a057d1 100644
--- a/phpBB/phpbb/console/command/db/migrate.php
+++ b/phpBB/phpbb/console/command/db/migrate.php
@@ -32,13 +32,17 @@ class migrate extends \phpbb\console\command\command
/** @var \phpbb\log\log */
protected $log;
- function __construct(\phpbb\user $user, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\log\log $log)
+ /** @var string phpBB root path */
+ protected $phpbb_root_path;
+
+ function __construct(\phpbb\user $user, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\log\log $log, $phpbb_root_path)
{
$this->migrator = $migrator;
$this->extension_manager = $extension_manager;
$this->config = $config;
$this->cache = $cache;
$this->log = $log;
+ $this->phpbb_root_path = $phpbb_root_path;
parent::__construct($user);
$this->user->add_lang(array('common', 'install', 'migrator'));
}
@@ -53,6 +57,8 @@ class migrate extends \phpbb\console\command\command
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $this->migrator->set_output_handler(new \phpbb\db\log_wrapper_migrator_output_handler($this->user, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log'));
+
$this->migrator->create_migrations_table();
$this->cache->purge();
@@ -61,8 +67,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 +77,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'])