From 99a932e0f93a6777fa78ca50a6cfff3d692515c8 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 2 May 2014 19:02:49 +0200 Subject: [ticket/12473] Add console command for database migration. PHPBB3-12473 --- phpBB/phpbb/console/command/db/migrate.php | 127 +++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 phpBB/phpbb/console/command/db/migrate.php (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php new file mode 100644 index 0000000000..79a803e8fb --- /dev/null +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -0,0 +1,127 @@ +migrator = $migrator; + $this->extension_manager = $extension_manager; + $this->config = $config; + $this->cache = $cache; + $this->log = $log; + $this->user = $user; + $this->user->add_lang(array('common', 'acp/common', 'install', 'migrator')); + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('db:migrate') + ->setDescription('Updates the database by applying migrations.') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->load_migrations(); + $orig_version = $this->config['version']; + while (!$this->migrator->finished()) + { + $migration_start_time = microtime(true); + + try + { + $this->migrator->update(); + } + catch (\phpbb\db\migration\exception $e) + { + $output->writeln($e->getLocalisedMessage($this->user)); + $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("$msg"); + } + 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("$msg"); + } + 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("$msg"); + } + } + + if ($orig_version != $this->config['version']) + { + $log->add('admin', 'LOG_UPDATE_DATABASE', $orig_version, $this->config['version']); + } + + $this->finalise_update(); + $output->writeln($this->user->lang['DATABASE_UPDATE_COMPLETE']); + } + + protected function load_migrations() + { + $migrations = $this->extension_manager + ->get_finder() + ->core_path('phpbb/db/migration/data/') + ->get_classes(); + $this->migrator->set_migrations($migrations); + } + + protected function finalise_update() + { + $this->cache->purge(); + $this->config->increment('assets_version', 1); + } +} -- cgit v1.2.1 From b302c6c1456f2fb9e13d02b1e9268fafda11726d Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Fri, 2 May 2014 19:31:48 +0200 Subject: [ticket/12474] Error messages should be displayed with tag PHPBB3-12474 --- phpBB/phpbb/console/command/db/migrate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 79a803e8fb..044929adaa 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -65,7 +65,7 @@ class migrate extends \phpbb\console\command\command } catch (\phpbb\db\migration\exception $e) { - $output->writeln($e->getLocalisedMessage($this->user)); + $output->writeln('' . $e->getLocalisedMessage($this->user) . ''); $this->finalise_update(); return 1; } -- cgit v1.2.1 From 4bbace8c0d9ed9810c85604cad7bf383e827fc5f Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Fri, 2 May 2014 19:40:18 +0200 Subject: [ticket/12475] Error in db:update console command PHPBB3-12475 --- phpBB/phpbb/console/command/db/migrate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 79a803e8fb..4c7284bc18 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -103,7 +103,7 @@ class migrate extends \phpbb\console\command\command if ($orig_version != $this->config['version']) { - $log->add('admin', 'LOG_UPDATE_DATABASE', $orig_version, $this->config['version']); + $this->log->add('admin', 'LOG_UPDATE_DATABASE', $orig_version, $this->config['version']); } $this->finalise_update(); -- cgit v1.2.1 From 3420f8f3201ac337434f73ee00bda6df7b378212 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 2 May 2014 19:55:19 +0200 Subject: [ticket/12475] Load extension migrations on cli updater too PHPBB3-12475 --- phpBB/phpbb/console/command/db/migrate.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index c7ccd4646e..08016ea4d8 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -114,7 +114,8 @@ class migrate extends \phpbb\console\command\command { $migrations = $this->extension_manager ->get_finder() - ->core_path('phpbb/db/migration/data/') + ->core_path('phpbb/db/migration/data/') + ->extension_directory('/migrations') ->get_classes(); $this->migrator->set_migrations($migrations); } -- cgit v1.2.1 From 03594b64438464ba7f234ce38d3344561bc0a66b Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 2 May 2014 20:03:40 +0200 Subject: [ticket/12475] Tabs, spaces, ... PHPBB3-12475 --- phpBB/phpbb/console/command/db/migrate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 08016ea4d8..16a09af6fc 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -114,8 +114,8 @@ class migrate extends \phpbb\console\command\command { $migrations = $this->extension_manager ->get_finder() - ->core_path('phpbb/db/migration/data/') - ->extension_directory('/migrations') + ->core_path('phpbb/db/migration/data/') + ->extension_directory('/migrations') ->get_classes(); $this->migrator->set_migrations($migrations); } -- cgit v1.2.1 From 66b7eaa1cabd98f00d5720e2382d672782e1e01a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 4 May 2014 22:20:22 +0200 Subject: [ticket/12499] Incorrect call to phpbb\log\log::add() in db:migrate https://tracker.phpbb.com/browse/PHPBB3-12499 PHPBB3-12499 --- phpBB/phpbb/console/command/db/migrate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 16a09af6fc..d984ac9e7a 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -103,7 +103,7 @@ class migrate extends \phpbb\console\command\command if ($orig_version != $this->config['version']) { - $this->log->add('admin', 'LOG_UPDATE_DATABASE', $orig_version, $this->config['version']); + $this->log->add('admin', ANONYMOUS, '', 'LOG_UPDATE_DATABASE', time(), array($orig_version, $this->config['version'])); } $this->finalise_update(); -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- phpBB/phpbb/console/command/db/migrate.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index d984ac9e7a..0f74664095 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -1,9 +1,13 @@ +* @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; -- cgit v1.2.1 From 6c9518ea3232d02605ea4bd57e1bf56a91d05855 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 4 Jun 2014 14:47:00 +0200 Subject: [ticket/12655] Don't require acp/common again in the commands PHPBB3-12655 --- phpBB/phpbb/console/command/db/migrate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 0f74664095..2abeaf5268 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -43,7 +43,7 @@ class migrate extends \phpbb\console\command\command $this->cache = $cache; $this->log = $log; $this->user = $user; - $this->user->add_lang(array('common', 'acp/common', 'install', 'migrator')); + $this->user->add_lang(array('common', 'install', 'migrator')); parent::__construct(); } -- cgit v1.2.1 From 07ce29c081c8bbd24a5094d89346be33dda583c5 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 17 Jul 2014 17:19:36 +0200 Subject: [ticket/12656] Pass user object into all console commands. PHPBB3-12656 --- phpBB/phpbb/console/command/db/migrate.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 2abeaf5268..758b125b13 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -32,19 +32,15 @@ class migrate extends \phpbb\console\command\command /** @var \phpbb\log\log */ protected $log; - /** @var \phpbb\user */ - protected $user; - - function __construct(\phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\log\log $log, \phpbb\user $user) + 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) { $this->migrator = $migrator; $this->extension_manager = $extension_manager; $this->config = $config; $this->cache = $cache; $this->log = $log; - $this->user = $user; + parent::__construct($user); $this->user->add_lang(array('common', 'install', 'migrator')); - parent::__construct(); } protected function configure() -- cgit v1.2.1 From 4092b63be39453f9a7ce4f985217099ab10aae90 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Wed, 23 Jul 2014 00:35:09 +0530 Subject: [ticket/12656] Use lang keys for CLI command descriptions PHPBB3-12656 --- phpBB/phpbb/console/command/db/migrate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 758b125b13..bb5f83b16f 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -47,7 +47,7 @@ class migrate extends \phpbb\console\command\command { $this ->setName('db:migrate') - ->setDescription('Updates the database by applying migrations.') + ->setDescription($this->user->lang('CLI_DESCRIPTION_DB_MIGRATE')) ; } -- cgit v1.2.1 From 8b8e09f4d52cfa2d9d951d827114b2ae510dbfc8 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 26 Jul 2014 11:50:28 +0200 Subject: [ticket/12870] Create the migrations table in db:migrate PHPBB3-12870 --- phpBB/phpbb/console/command/db/migrate.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 758b125b13..29f0fe7c16 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -32,13 +32,21 @@ 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 \phpbb\db\tools */ + protected $db_tools; + + /** @var string */ + protected $table_prefix; + + 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\db\tools $db_tools, $table_prefix) { $this->migrator = $migrator; $this->extension_manager = $extension_manager; $this->config = $config; $this->cache = $cache; $this->log = $log; + $this->db_tools = $db_tools; + $this->table_prefix = $table_prefix; parent::__construct($user); $this->user->add_lang(array('common', 'install', 'migrator')); } @@ -53,6 +61,23 @@ class migrate extends \phpbb\console\command\command protected function execute(InputInterface $input, OutputInterface $output) { + // Make sure migrations have been installed. + if (!$this->db_tools->sql_table_exists($this->table_prefix . 'migrations')) + { + $this->db_tools->sql_create_table($this->table_prefix . 'migrations', array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', + )); + } + $this->load_migrations(); $orig_version = $this->config['version']; while (!$this->migrator->finished()) -- cgit v1.2.1 From a8e81b6e9f42c3187d7b17c6bb5da052c28944a6 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 27 Jul 2014 11:08:13 +0200 Subject: [ticket/12870] Create the migrations table with a method in the migrator PHPBB3-12870 --- phpBB/phpbb/console/command/db/migrate.php | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 29f0fe7c16..dc16ed0699 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -32,21 +32,13 @@ class migrate extends \phpbb\console\command\command /** @var \phpbb\log\log */ protected $log; - /** @var \phpbb\db\tools */ - protected $db_tools; - - /** @var string */ - protected $table_prefix; - - 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\db\tools $db_tools, $table_prefix) + 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) { $this->migrator = $migrator; $this->extension_manager = $extension_manager; $this->config = $config; $this->cache = $cache; $this->log = $log; - $this->db_tools = $db_tools; - $this->table_prefix = $table_prefix; parent::__construct($user); $this->user->add_lang(array('common', 'install', 'migrator')); } @@ -61,22 +53,7 @@ class migrate extends \phpbb\console\command\command protected function execute(InputInterface $input, OutputInterface $output) { - // Make sure migrations have been installed. - if (!$this->db_tools->sql_table_exists($this->table_prefix . 'migrations')) - { - $this->db_tools->sql_create_table($this->table_prefix . 'migrations', array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', - )); - } + $this->migrator->create_migrations_table(); $this->load_migrations(); $orig_version = $this->config['version']; -- cgit v1.2.1 From 72ee4b3a7c4fca67cb226dab3ed27a8afa903144 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 10 Sep 2014 12:08:13 +0200 Subject: [ticket/12963] Load extensions migrations from /migration PHPBB3-12963 --- phpBB/phpbb/console/command/db/migrate.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index c3caae5f70..a25886fb82 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -117,8 +117,17 @@ class migrate extends \phpbb\console\command\command $migrations = $this->extension_manager ->get_finder() ->core_path('phpbb/db/migration/data/') + ->extension_directory('/migration') + ->get_classes(); + + // @deprecated to be removed in 3.2 final + $migrations_deprecated = $this->extension_manager + ->get_finder() ->extension_directory('/migrations') ->get_classes(); + + $migrations = array_merge($migrations, $migrations_deprecated); + $this->migrator->set_migrations($migrations); } -- cgit v1.2.1 From 8b16d3141396a11db3ab4ade49af91f2477f5fb6 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 16 Sep 2014 20:18:10 +0200 Subject: [ticket/12963] Edit deprecation message PHPBB3-12963 --- phpBB/phpbb/console/command/db/migrate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index a25886fb82..68638a9515 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -120,7 +120,7 @@ class migrate extends \phpbb\console\command\command ->extension_directory('/migration') ->get_classes(); - // @deprecated to be removed in 3.2 final + // @deprecated 3.1.0-RC4 (To be removed: 3.2.0) $migrations_deprecated = $this->extension_manager ->get_finder() ->extension_directory('/migrations') -- cgit v1.2.1 From c220fa89a1bf5652df6512ad78eb9ba550fe465e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 18 Sep 2014 10:42:21 +0200 Subject: [ticket/12963] Revert back to "migrations" folder name for extensions The issues that can be created with the name change are just too much PHPBB3-12963 --- phpBB/phpbb/console/command/db/migrate.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 68638a9515..86545c237d 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -117,17 +117,9 @@ class migrate extends \phpbb\console\command\command $migrations = $this->extension_manager ->get_finder() ->core_path('phpbb/db/migration/data/') - ->extension_directory('/migration') - ->get_classes(); - - // @deprecated 3.1.0-RC4 (To be removed: 3.2.0) - $migrations_deprecated = $this->extension_manager - ->get_finder() ->extension_directory('/migrations') ->get_classes(); - $migrations = array_merge($migrations, $migrations_deprecated); - $this->migrator->set_migrations($migrations); } -- cgit v1.2.1 From bda68793054af20d817a81717f585de55d8dd254 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 5 Oct 2014 12:25:14 +0200 Subject: [ticket/12368] Always clean the cache prior to run the migrations PHPBB3-12368 --- phpBB/phpbb/console/command/db/migrate.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 86545c237d..c760cde5b5 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -55,6 +55,8 @@ class migrate extends \phpbb\console\command\command { $this->migrator->create_migrations_table(); + $this->cache->purge(); + $this->load_migrations(); $orig_version = $this->config['version']; while (!$this->migrator->finished()) -- cgit v1.2.1 From 56d7c2c6ed3e5924aeced53a163bfd1aa8288034 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 14 Oct 2014 17:58:29 +0200 Subject: [ticket/13126] Improve the feedback when running the migrations PHPBB3-13126 --- phpBB/phpbb/console/command/db/migrate.php | 56 +++++++++++++----------------- 1 file changed, 24 insertions(+), 32 deletions(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') 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 = '' . $final_message . ''; + } + else if ($verbosity === \phpbb\db\migrator_output_handler::VERBOSITY_VERY_VERBOSE) + { + $final_message = '' . $final_message . ''; + } + + $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("$msg"); - } - 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("$msg"); - } - 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("$msg"); - } } if ($orig_version != $this->config['version']) -- cgit v1.2.1 From 58075e25e8173ec663e4e8908d1963b1947a225b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 16 Oct 2014 01:34:23 +0200 Subject: [ticket/13126] Extends migrator_output_handler instead of using a closure PHPBB3-13126 --- phpBB/phpbb/console/command/db/migrate.php | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index ecb84d7401..9d4b4a0c4d 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -53,29 +53,7 @@ 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 = '' . $final_message . ''; - } - else if ($verbosity === \phpbb\db\migrator_output_handler::VERBOSITY_VERY_VERBOSE) - { - $final_message = '' . $final_message . ''; - } - - $output->writeln($final_message); - } - } - ) - ); + $this->migrator->set_output_handler(new console_migrator_output_handler($this->user, $output)); $this->migrator->create_migrations_table(); -- cgit v1.2.1 From b27b9a6984f2ed3a9a186133657d30b4cca883c0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 24 Oct 2014 13:33:26 -0700 Subject: [ticket/13211] Move console migrator output handler to db folder PHPBB3-13211 --- phpBB/phpbb/console/command/db/migrate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 9d4b4a0c4d..15349e1230 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -53,7 +53,7 @@ class migrate extends \phpbb\console\command\command protected function execute(InputInterface $input, OutputInterface $output) { - $this->migrator->set_output_handler(new console_migrator_output_handler($this->user, $output)); + $this->migrator->set_output_handler(new \phpbb\db\console_migrator_output_handler($this->user, $output)); $this->migrator->create_migrations_table(); -- cgit v1.2.1 From 84434630065c2491cfa5e65a69b8b22d6844b6f4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 25 Oct 2014 11:55:15 -0700 Subject: [ticket/13211] Also use log wrapper output handler for console migrations PHPBB3-13211 --- phpBB/phpbb/console/command/db/migrate.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 15349e1230..76550a8429 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,7 +57,7 @@ class migrate extends \phpbb\console\command\command protected function execute(InputInterface $input, OutputInterface $output) { - $this->migrator->set_output_handler(new \phpbb\db\console_migrator_output_handler($this->user, $output)); + $this->migrator->set_output_handler(new \phpbb\db\log_wrapper_migrator_output_handler($this->user, new \phpbb\db\console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log')); $this->migrator->create_migrations_table(); -- cgit v1.2.1 From 078e0c1e440f7f906b670348e8da00141e245876 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 25 Oct 2014 12:03:13 -0700 Subject: [ticket/13211] Move console migrator output handler back to console folder PHPBB3-13211 --- phpBB/phpbb/console/command/db/migrate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/db/migrate.php') diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php index 76550a8429..87c2a057d1 100644 --- a/phpBB/phpbb/console/command/db/migrate.php +++ b/phpBB/phpbb/console/command/db/migrate.php @@ -57,7 +57,7 @@ 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 \phpbb\db\console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log')); + $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(); -- cgit v1.2.1