aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/console/command
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/console/command')
-rw-r--r--phpBB/phpbb/console/command/cache/purge.php8
-rw-r--r--phpBB/phpbb/console/command/config/command.php2
-rw-r--r--phpBB/phpbb/console/command/config/delete.php9
-rw-r--r--phpBB/phpbb/console/command/config/get.php7
-rw-r--r--phpBB/phpbb/console/command/config/increment.php7
-rw-r--r--phpBB/phpbb/console/command/config/set.php7
-rw-r--r--phpBB/phpbb/console/command/config/set_atomic.php7
-rw-r--r--phpBB/phpbb/console/command/cron/cron_list.php41
-rw-r--r--phpBB/phpbb/console/command/db/list_command.php30
-rw-r--r--phpBB/phpbb/console/command/db/migrate.php13
-rw-r--r--phpBB/phpbb/console/command/db/migration_command.php2
-rw-r--r--phpBB/phpbb/console/command/db/revert.php34
-rw-r--r--phpBB/phpbb/console/command/dev/migration_tips.php2
-rw-r--r--phpBB/phpbb/console/command/extension/disable.php14
-rw-r--r--phpBB/phpbb/console/command/extension/enable.php14
-rw-r--r--phpBB/phpbb/console/command/extension/purge.php7
-rw-r--r--phpBB/phpbb/console/command/extension/show.php28
-rw-r--r--phpBB/phpbb/console/command/fixup/recalculate_email_hash.php17
-rw-r--r--phpBB/phpbb/console/command/reparser/list_all.php11
-rw-r--r--phpBB/phpbb/console/command/reparser/reparse.php16
-rw-r--r--phpBB/phpbb/console/command/update/check.php331
21 files changed, 475 insertions, 132 deletions
diff --git a/phpBB/phpbb/console/command/cache/purge.php b/phpBB/phpbb/console/command/cache/purge.php
index d0c2ef6f72..b7a51b2bb4 100644
--- a/phpBB/phpbb/console/command/cache/purge.php
+++ b/phpBB/phpbb/console/command/cache/purge.php
@@ -14,6 +14,7 @@ namespace phpbb\console\command\cache;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class purge extends \phpbb\console\command\command
{
@@ -39,7 +40,7 @@ class purge extends \phpbb\console\command\command
* @param \phpbb\cache\driver\driver_interface $cache Cache instance
* @param \phpbb\db\driver\driver_interface $db Database connection
* @param \phpbb\auth\auth $auth Auth instance
- * @param \phpbb\log\log $log Logger instance
+ * @param \phpbb\log\log_interface $log Logger instance
* @param \phpbb\config\config $config Config instance
*/
public function __construct(\phpbb\user $user, \phpbb\cache\driver\driver_interface $cache, \phpbb\db\driver\driver_interface $db, \phpbb\auth\auth $auth, \phpbb\log\log_interface $log, \phpbb\config\config $config)
@@ -71,7 +72,7 @@ class purge extends \phpbb\console\command\command
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
- * @return null
+ * @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
@@ -84,6 +85,7 @@ class purge extends \phpbb\console\command\command
$this->log->add('admin', ANONYMOUS, '', 'LOG_PURGE_CACHE', time(), array());
- $output->writeln($this->user->lang('PURGE_CACHE_SUCCESS'));
+ $io = new SymfonyStyle($input, $output);
+ $io->success($this->user->lang('PURGE_CACHE_SUCCESS'));
}
}
diff --git a/phpBB/phpbb/console/command/config/command.php b/phpBB/phpbb/console/command/config/command.php
index f0ad5d4d19..19f67d3b6c 100644
--- a/phpBB/phpbb/console/command/config/command.php
+++ b/phpBB/phpbb/console/command/config/command.php
@@ -17,7 +17,7 @@ abstract class command extends \phpbb\console\command\command
/** @var \phpbb\config\config */
protected $config;
- function __construct(\phpbb\user $user, \phpbb\config\config $config)
+ public function __construct(\phpbb\user $user, \phpbb\config\config $config)
{
$this->config = $config;
diff --git a/phpBB/phpbb/console/command/config/delete.php b/phpBB/phpbb/console/command/config/delete.php
index efd276d7e3..2da0801337 100644
--- a/phpBB/phpbb/console/command/config/delete.php
+++ b/phpBB/phpbb/console/command/config/delete.php
@@ -15,6 +15,7 @@ namespace phpbb\console\command\config;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class delete extends command
{
@@ -42,22 +43,24 @@ class delete extends command
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
- * @return null
+ * @return void
* @see \phpbb\config\config::delete()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$key = $input->getArgument('key');
if (isset($this->config[$key]))
{
$this->config->delete($key);
- $output->writeln('<info>' . $this->user->lang('CLI_CONFIG_DELETE_SUCCESS', $key) . '</info>');
+ $io->success($this->user->lang('CLI_CONFIG_DELETE_SUCCESS', $key));
}
else
{
- $output->writeln('<error>' . $this->user->lang('CLI_CONFIG_NOT_EXISTS', $key) . '</error>');
+ $io->error($this->user->lang('CLI_CONFIG_NOT_EXISTS', $key));
}
}
}
diff --git a/phpBB/phpbb/console/command/config/get.php b/phpBB/phpbb/console/command/config/get.php
index 9c03b49a3d..f065787110 100644
--- a/phpBB/phpbb/console/command/config/get.php
+++ b/phpBB/phpbb/console/command/config/get.php
@@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class get extends command
{
@@ -49,11 +50,13 @@ class get extends command
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
- * @return null
+ * @return void
* @see \phpbb\config\config::offsetGet()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$key = $input->getArgument('key');
if (isset($this->config[$key]) && $input->getOption('no-newline'))
@@ -66,7 +69,7 @@ class get extends command
}
else
{
- $output->writeln('<error>' . $this->user->lang('CLI_CONFIG_NOT_EXISTS', $key) . '</error>');
+ $io->error($this->user->lang('CLI_CONFIG_NOT_EXISTS', $key));
}
}
}
diff --git a/phpBB/phpbb/console/command/config/increment.php b/phpBB/phpbb/console/command/config/increment.php
index b4d7438b66..647380a0bf 100644
--- a/phpBB/phpbb/console/command/config/increment.php
+++ b/phpBB/phpbb/console/command/config/increment.php
@@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class increment extends command
{
@@ -54,17 +55,19 @@ class increment extends command
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
- * @return null
+ * @return void
* @see \phpbb\config\config::increment()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$key = $input->getArgument('key');
$increment = $input->getArgument('increment');
$use_cache = !$input->getOption('dynamic');
$this->config->increment($key, $increment, $use_cache);
- $output->writeln('<info>' . $this->user->lang('CLI_CONFIG_INCREMENT_SUCCESS', $key) . '</info>');
+ $io->success($this->user->lang('CLI_CONFIG_INCREMENT_SUCCESS', $key));
}
}
diff --git a/phpBB/phpbb/console/command/config/set.php b/phpBB/phpbb/console/command/config/set.php
index 695de31013..e9f7f8f91e 100644
--- a/phpBB/phpbb/console/command/config/set.php
+++ b/phpBB/phpbb/console/command/config/set.php
@@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class set extends command
{
@@ -54,17 +55,19 @@ class set extends command
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
- * @return null
+ * @return void
* @see \phpbb\config\config::set()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$key = $input->getArgument('key');
$value = $input->getArgument('value');
$use_cache = !$input->getOption('dynamic');
$this->config->set($key, $value, $use_cache);
- $output->writeln('<info>' . $this->user->lang('CLI_CONFIG_SET_SUCCESS', $key) . '</info>');
+ $io->success($this->user->lang('CLI_CONFIG_SET_SUCCESS', $key));
}
}
diff --git a/phpBB/phpbb/console/command/config/set_atomic.php b/phpBB/phpbb/console/command/config/set_atomic.php
index e8c69a0885..475d8a9271 100644
--- a/phpBB/phpbb/console/command/config/set_atomic.php
+++ b/phpBB/phpbb/console/command/config/set_atomic.php
@@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class set_atomic extends command
{
@@ -65,6 +66,8 @@ class set_atomic extends command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$key = $input->getArgument('key');
$old_value = $input->getArgument('old');
$new_value = $input->getArgument('new');
@@ -72,12 +75,12 @@ class set_atomic extends command
if ($this->config->set_atomic($key, $old_value, $new_value, $use_cache))
{
- $output->writeln('<info>' . $this->user->lang('CLI_CONFIG_SET_SUCCESS', $key) . '</info>');
+ $io->success($this->user->lang('CLI_CONFIG_SET_SUCCESS', $key));
return 0;
}
else
{
- $output->writeln('<error>' . $this->user->lang('CLI_CONFIG_SET_FAILURE', $key) . '</error>');
+ $io->error($this->user->lang('CLI_CONFIG_SET_FAILURE', $key));
return 1;
}
}
diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php
index c515fd9e80..ea61e45235 100644
--- a/phpBB/phpbb/console/command/cron/cron_list.php
+++ b/phpBB/phpbb/console/command/cron/cron_list.php
@@ -14,6 +14,7 @@ namespace phpbb\console\command\cron;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class cron_list extends \phpbb\console\command\command
{
@@ -51,61 +52,43 @@ class cron_list extends \phpbb\console\command\command
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
- * @return null
+ * @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$tasks = $this->cron_manager->get_tasks();
if (empty($tasks))
{
- $output->writeln($this->user->lang('CRON_NO_TASKS'));
+ $io->error($this->user->lang('CRON_NO_TASKS'));
return;
}
- $ready_tasks = array();
- $not_ready_tasks = array();
+ $ready_tasks = $not_ready_tasks = array();
foreach ($tasks as $task)
{
if ($task->is_ready())
{
- $ready_tasks[] = $task;
+ $ready_tasks[] = $task->get_name();
}
else
{
- $not_ready_tasks[] = $task;
+ $not_ready_tasks[] = $task->get_name();
}
}
if (!empty($ready_tasks))
{
- $output->writeln('<info>' . $this->user->lang('TASKS_READY') . '</info>');
- $this->print_tasks_names($ready_tasks, $output);
- }
-
- if (!empty($ready_tasks) && !empty($not_ready_tasks))
- {
- $output->writeln('');
+ $io->title($this->user->lang('TASKS_READY'));
+ $io->listing($ready_tasks);
}
if (!empty($not_ready_tasks))
{
- $output->writeln('<info>' . $this->user->lang('TASKS_NOT_READY') . '</info>');
- $this->print_tasks_names($not_ready_tasks, $output);
- }
- }
-
- /**
- * Print a list of cron jobs
- *
- * @param array $tasks A list of task to display
- * @param OutputInterface $output An OutputInterface instance
- */
- protected function print_tasks_names(array $tasks, OutputInterface $output)
- {
- foreach ($tasks as $task)
- {
- $output->writeln($task->get_name());
+ $io->title($this->user->lang('TASKS_NOT_READY'));
+ $io->listing($not_ready_tasks);
}
}
}
diff --git a/phpBB/phpbb/console/command/db/list_command.php b/phpBB/phpbb/console/command/db/list_command.php
index 708107b592..77f26dd786 100644
--- a/phpBB/phpbb/console/command/db/list_command.php
+++ b/phpBB/phpbb/console/command/db/list_command.php
@@ -15,6 +15,7 @@ namespace phpbb\console\command\db;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class list_command extends \phpbb\console\command\db\migration_command
{
@@ -34,6 +35,8 @@ class list_command extends \phpbb\console\command\db\migration_command
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$show_installed = !$input->getOption('available');
$installed = $available = array();
@@ -51,23 +54,28 @@ class list_command extends \phpbb\console\command\db\migration_command
if ($show_installed)
{
- $output->writeln('<info>' . $this->user->lang('CLI_MIGRATIONS_INSTALLED') . $this->user->lang('COLON') . '</info>');
- $output->writeln($installed);
+ $io->section($this->user->lang('CLI_MIGRATIONS_INSTALLED'));
- if (empty($installed))
+ if (!empty($installed))
{
- $output->writeln($this->user->lang('CLI_MIGRATIONS_EMPTY'));
+ $io->listing($installed);
+ }
+ else
+ {
+ $io->text($this->user->lang('CLI_MIGRATIONS_EMPTY'));
+ $io->newLine();
}
-
- $output->writeln('');
}
- $output->writeln('<info>' . $this->user->lang('CLI_MIGRATIONS_AVAILABLE') . $this->user->lang('COLON') . '</info>');
- $output->writeln($available);
-
- if (empty($available))
+ $io->section($this->user->lang('CLI_MIGRATIONS_AVAILABLE'));
+ if (!empty($available))
+ {
+ $io->listing($available);
+ }
+ else
{
- $output->writeln($this->user->lang('CLI_MIGRATIONS_EMPTY'));
+ $io->text($this->user->lang('CLI_MIGRATIONS_EMPTY'));
+ $io->newLine();
}
}
}
diff --git a/phpBB/phpbb/console/command/db/migrate.php b/phpBB/phpbb/console/command/db/migrate.php
index ae4211f7be..4270e2d703 100644
--- a/phpBB/phpbb/console/command/db/migrate.php
+++ b/phpBB/phpbb/console/command/db/migrate.php
@@ -15,6 +15,7 @@ namespace phpbb\console\command\db;
use phpbb\db\output_handler\log_wrapper_migrator_output_handler;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class migrate extends \phpbb\console\command\db\migration_command
{
@@ -30,26 +31,28 @@ class migrate extends \phpbb\console\command\db\migration_command
/** @var \phpbb\language\language */
protected $language;
- function __construct(\phpbb\user $user, \phpbb\language\language $language, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\log\log $log, \phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path)
+ public function __construct(\phpbb\user $user, \phpbb\language\language $language, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\log\log $log, \phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path)
{
$this->language = $language;
$this->log = $log;
$this->filesystem = $filesystem;
$this->phpbb_root_path = $phpbb_root_path;
parent::__construct($user, $migrator, $extension_manager, $config, $cache);
- $this->user->add_lang(array('common', 'install', 'migrator'));
+ $this->language->add_lang(array('common', 'install', 'migrator'));
}
protected function configure()
{
$this
->setName('db:migrate')
- ->setDescription($this->user->lang('CLI_DESCRIPTION_DB_MIGRATE'))
+ ->setDescription($this->language->lang('CLI_DESCRIPTION_DB_MIGRATE'))
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
$this->migrator->create_migrations_table();
@@ -66,7 +69,7 @@ class migrate extends \phpbb\console\command\db\migration_command
}
catch (\phpbb\db\migration\exception $e)
{
- $output->writeln('<error>' . $e->getLocalisedMessage($this->user) . '</error>');
+ $io->error($e->getLocalisedMessage($this->user));
$this->finalise_update();
return 1;
}
@@ -78,6 +81,6 @@ class migrate extends \phpbb\console\command\db\migration_command
}
$this->finalise_update();
- $output->writeln($this->user->lang['DATABASE_UPDATE_COMPLETE']);
+ $io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL'));
}
}
diff --git a/phpBB/phpbb/console/command/db/migration_command.php b/phpBB/phpbb/console/command/db/migration_command.php
index b951560588..851f404fab 100644
--- a/phpBB/phpbb/console/command/db/migration_command.php
+++ b/phpBB/phpbb/console/command/db/migration_command.php
@@ -26,7 +26,7 @@ abstract class migration_command extends \phpbb\console\command\command
/** @var \phpbb\cache\service */
protected $cache;
- function __construct(\phpbb\user $user, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache)
+ public function __construct(\phpbb\user $user, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache)
{
$this->migrator = $migrator;
$this->extension_manager = $extension_manager;
diff --git a/phpBB/phpbb/console/command/db/revert.php b/phpBB/phpbb/console/command/db/revert.php
index 3fa2e17515..3c79d8c554 100644
--- a/phpBB/phpbb/console/command/db/revert.php
+++ b/phpBB/phpbb/console/command/db/revert.php
@@ -16,42 +16,27 @@ use phpbb\db\output_handler\log_wrapper_migrator_output_handler;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
-class revert extends \phpbb\console\command\db\migration_command
+class revert extends \phpbb\console\command\db\migrate
{
- /** @var string phpBB root path */
- protected $phpbb_root_path;
-
- /** @var \phpbb\filesystem\filesystem_interface */
- protected $filesystem;
-
- /** @var \phpbb\language\language */
- protected $language;
-
- function __construct(\phpbb\user $user, \phpbb\language\language $language, \phpbb\db\migrator $migrator, \phpbb\extension\manager $extension_manager, \phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path)
- {
- $this->filesystem = $filesystem;
- $this->language = $language;
- $this->phpbb_root_path = $phpbb_root_path;
- parent::__construct($user, $migrator, $extension_manager, $config, $cache);
- $this->user->add_lang(array('common', 'migrator'));
- }
-
protected function configure()
{
$this
->setName('db:revert')
- ->setDescription($this->user->lang('CLI_DESCRIPTION_DB_REVERT'))
+ ->setDescription($this->language->lang('CLI_DESCRIPTION_DB_REVERT'))
->addArgument(
'name',
InputArgument::REQUIRED,
- $this->user->lang('CLI_MIGRATION_NAME')
+ $this->language->lang('CLI_MIGRATION_NAME')
)
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$name = str_replace('/', '\\', $input->getArgument('name'));
$this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
@@ -60,12 +45,12 @@ class revert extends \phpbb\console\command\db\migration_command
if (!in_array($name, $this->load_migrations()))
{
- $output->writeln('<error>' . $this->user->lang('MIGRATION_NOT_VALID', $name) . '</error>');
+ $io->error($this->language->lang('MIGRATION_NOT_VALID', $name));
return 1;
}
else if ($this->migrator->migration_state($name) === false)
{
- $output->writeln('<error>' . $this->user->lang('MIGRATION_NOT_INSTALLED', $name) . '</error>');
+ $io->error($this->language->lang('MIGRATION_NOT_INSTALLED', $name));
return 1;
}
@@ -78,11 +63,12 @@ class revert extends \phpbb\console\command\db\migration_command
}
catch (\phpbb\db\migration\exception $e)
{
- $output->writeln('<error>' . $e->getLocalisedMessage($this->user) . '</error>');
+ $io->error($e->getLocalisedMessage($this->user));
$this->finalise_update();
return 1;
}
$this->finalise_update();
+ $io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL'));
}
}
diff --git a/phpBB/phpbb/console/command/dev/migration_tips.php b/phpBB/phpbb/console/command/dev/migration_tips.php
index f9047bdac8..2ca0ddde2f 100644
--- a/phpBB/phpbb/console/command/dev/migration_tips.php
+++ b/phpBB/phpbb/console/command/dev/migration_tips.php
@@ -20,7 +20,7 @@ class migration_tips extends \phpbb\console\command\command
/** @var \phpbb\extension\manager */
protected $extension_manager;
- function __construct(\phpbb\user $user, \phpbb\extension\manager $extension_manager)
+ public function __construct(\phpbb\user $user, \phpbb\extension\manager $extension_manager)
{
$this->extension_manager = $extension_manager;
parent::__construct($user);
diff --git a/phpBB/phpbb/console/command/extension/disable.php b/phpBB/phpbb/console/command/extension/disable.php
index 1eee16cbd9..b2e10fb960 100644
--- a/phpBB/phpbb/console/command/extension/disable.php
+++ b/phpBB/phpbb/console/command/extension/disable.php
@@ -15,6 +15,7 @@ namespace phpbb\console\command\extension;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class disable extends command
{
@@ -33,19 +34,28 @@ class disable extends command
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$name = $input->getArgument('extension-name');
+
+ if (!$this->manager->is_enabled($name))
+ {
+ $io->error($this->user->lang('CLI_EXTENSION_DISABLED', $name));
+ return 2;
+ }
+
$this->manager->disable($name);
$this->manager->load_extensions();
if ($this->manager->is_enabled($name))
{
- $output->writeln('<error>' . $this->user->lang('CLI_EXTENSION_DISABLE_FAILURE', $name) . '</error>');
+ $io->error($this->user->lang('CLI_EXTENSION_DISABLE_FAILURE', $name));
return 1;
}
else
{
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_DISABLE', time(), array($name));
- $output->writeln('<info>' . $this->user->lang('CLI_EXTENSION_DISABLE_SUCCESS', $name) . '</info>');
+ $io->success($this->user->lang('CLI_EXTENSION_DISABLE_SUCCESS', $name));
return 0;
}
}
diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php
index 59ff11e9b7..a8312d5c15 100644
--- a/phpBB/phpbb/console/command/extension/enable.php
+++ b/phpBB/phpbb/console/command/extension/enable.php
@@ -15,6 +15,7 @@ namespace phpbb\console\command\extension;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class enable extends command
{
@@ -33,19 +34,28 @@ class enable extends command
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$name = $input->getArgument('extension-name');
+
+ if ($this->manager->is_enabled($name))
+ {
+ $io->error($this->user->lang('CLI_EXTENSION_ENABLED', $name));
+ return 2;
+ }
+
$this->manager->enable($name);
$this->manager->load_extensions();
if ($this->manager->is_enabled($name))
{
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name));
- $output->writeln('<info>' . $this->user->lang('CLI_EXTENSION_ENABLE_SUCCESS', $name) . '</info>');
+ $io->success($this->user->lang('CLI_EXTENSION_ENABLE_SUCCESS', $name));
return 0;
}
else
{
- $output->writeln('<error>' . $this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name) . '</error>');
+ $io->error($this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name));
return 1;
}
}
diff --git a/phpBB/phpbb/console/command/extension/purge.php b/phpBB/phpbb/console/command/extension/purge.php
index 517e9a74c9..25bde503f7 100644
--- a/phpBB/phpbb/console/command/extension/purge.php
+++ b/phpBB/phpbb/console/command/extension/purge.php
@@ -15,6 +15,7 @@ namespace phpbb\console\command\extension;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class purge extends command
{
@@ -33,19 +34,21 @@ class purge extends command
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$name = $input->getArgument('extension-name');
$this->manager->purge($name);
$this->manager->load_extensions();
if ($this->manager->is_enabled($name))
{
- $output->writeln('<error>' . $this->user->lang('CLI_EXTENSION_PURGE_FAILURE', $name) . '</error>');
+ $io->error($this->user->lang('CLI_EXTENSION_PURGE_FAILURE', $name));
return 1;
}
else
{
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_PURGE', time(), array($name));
- $output->writeln('<info>' . $this->user->lang('CLI_EXTENSION_PURGE_SUCCESS', $name) . '</info>');
+ $io->success($this->user->lang('CLI_EXTENSION_PURGE_SUCCESS', $name));
return 0;
}
}
diff --git a/phpBB/phpbb/console/command/extension/show.php b/phpBB/phpbb/console/command/extension/show.php
index f9322034d7..7bad0c0a5a 100644
--- a/phpBB/phpbb/console/command/extension/show.php
+++ b/phpBB/phpbb/console/command/extension/show.php
@@ -14,6 +14,7 @@ namespace phpbb\console\command\extension;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class show extends command
{
@@ -27,36 +28,27 @@ class show extends command
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$this->manager->load_extensions();
$all = array_keys($this->manager->all_available());
if (empty($all))
{
- $output->writeln('<comment>' . $this->user->lang('CLI_EXTENSION_NOT_FOUND') . '</comment>');
+ $io->note($this->user->lang('CLI_EXTENSION_NOT_FOUND'));
return 3;
}
$enabled = array_keys($this->manager->all_enabled());
- $this->print_extension_list($output, $this->user->lang('CLI_EXTENSIONS_ENABLED') . $this->user->lang('COLON'), $enabled);
-
- $output->writeln('');
+ $io->section($this->user->lang('CLI_EXTENSIONS_ENABLED'));
+ $io->listing($enabled);
$disabled = array_keys($this->manager->all_disabled());
- $this->print_extension_list($output, $this->user->lang('CLI_EXTENSIONS_DISABLED') . $this->user->lang('COLON'), $disabled);
-
- $output->writeln('');
+ $io->section($this->user->lang('CLI_EXTENSIONS_DISABLED'));
+ $io->listing($disabled);
$purged = array_diff($all, $enabled, $disabled);
- $this->print_extension_list($output, $this->user->lang('CLI_EXTENSIONS_AVAILABLE') . $this->user->lang('COLON'), $purged);
- }
-
- protected function print_extension_list(OutputInterface $output, $type, array $extensions)
- {
- $output->writeln("<info>$type</info>");
-
- foreach ($extensions as $extension)
- {
- $output->writeln(" - $extension");
- }
+ $io->section($this->user->lang('CLI_EXTENSIONS_AVAILABLE'));
+ $io->listing($purged);
}
}
diff --git a/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php b/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php
index ec4e1b0ee7..6f7096296d 100644
--- a/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php
+++ b/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php
@@ -14,13 +14,14 @@ namespace phpbb\console\command\fixup;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class recalculate_email_hash extends \phpbb\console\command\command
{
/** @var \phpbb\db\driver\driver_interface */
protected $db;
- function __construct(\phpbb\user $user, \phpbb\db\driver\driver_interface $db)
+ public function __construct(\phpbb\user $user, \phpbb\db\driver\driver_interface $db)
{
$this->db = $db;
@@ -37,6 +38,8 @@ class recalculate_email_hash extends \phpbb\console\command\command
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
$sql = 'SELECT user_id, user_email, user_email_hash
FROM ' . USERS_TABLE . '
WHERE user_type <> ' . USER_IGNORE . "
@@ -59,17 +62,15 @@ class recalculate_email_hash extends \phpbb\console\command\command
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG)
{
- $output->writeln(sprintf(
- 'user_id %d, email %s => %s',
- $row['user_id'],
- $row['user_email'],
- $user_email_hash
- ));
+ $io->table(
+ array('user_id', 'user_email', 'user_email_hash'),
+ array(array($row['user_id'], $row['user_email'], $user_email_hash))
+ );
}
}
}
$this->db->sql_freeresult($result);
- $output->writeln('<info>' . $this->user->lang('CLI_FIXUP_RECALCULATE_EMAIL_HASH_SUCCESS') . '</info>');
+ $io->success($this->user->lang('CLI_FIXUP_RECALCULATE_EMAIL_HASH_SUCCESS'));
}
}
diff --git a/phpBB/phpbb/console/command/reparser/list_all.php b/phpBB/phpbb/console/command/reparser/list_all.php
index e42c3ac782..a79578abf0 100644
--- a/phpBB/phpbb/console/command/reparser/list_all.php
+++ b/phpBB/phpbb/console/command/reparser/list_all.php
@@ -15,6 +15,7 @@ namespace phpbb\console\command\reparser;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class list_all extends \phpbb\console\command\command
{
@@ -33,10 +34,10 @@ class list_all extends \phpbb\console\command\command
{
parent::__construct($user);
$this->reparser_names = array();
- foreach ($reparsers as $name => $reparser)
+ foreach ($reparsers as $reparser)
{
// Store the names without the "text_reparser." prefix
- $this->reparser_names[] = preg_replace('(^text_reparser\\.)', '', $name);
+ $this->reparser_names[] = $reparser->get_name();
}
}
@@ -54,7 +55,7 @@ class list_all extends \phpbb\console\command\command
}
/**
- * Executes the command reparser:reparse
+ * Executes the command reparser:list
*
* @param InputInterface $input
* @param OutputInterface $output
@@ -62,7 +63,9 @@ class list_all extends \phpbb\console\command\command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $output->writeln('<info>' . implode(', ', $this->reparser_names) . '</info>');
+ $io = new SymfonyStyle($input, $output);
+ $io->section($this->user->lang('CLI_DESCRIPTION_REPARSER_AVAILABLE'));
+ $io->listing($this->reparser_names);
return 0;
}
diff --git a/phpBB/phpbb/console/command/reparser/reparse.php b/phpBB/phpbb/console/command/reparser/reparse.php
index cebeee0919..f285977ea2 100644
--- a/phpBB/phpbb/console/command/reparser/reparse.php
+++ b/phpBB/phpbb/console/command/reparser/reparse.php
@@ -140,13 +140,9 @@ class reparse extends \phpbb\console\command\command
}
$name = $input->getArgument('reparser-name');
- if (isset($name))
+ if ($name)
{
- // Allow "post_text" to be an alias for "text_reparser.post_text"
- if (!isset($this->reparsers[$name]))
- {
- $name = 'text_reparser.' . $name;
- }
+ $name = $this->reparser_manager->find_reparser($name);
$this->reparse($name);
}
else
@@ -187,7 +183,7 @@ class reparse extends \phpbb\console\command\command
/**
* Reparse all text handled by given reparser within given range
*
- * @param string $name Reparser name
+ * @param string $name Reparser service name
*/
protected function reparse($name)
{
@@ -218,10 +214,10 @@ class reparse extends \phpbb\console\command\command
return;
}
- $this->io->section($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', preg_replace('(^text_reparser\\.)', '', $name), $min, $max));
+ $this->io->section($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', $reparser->get_name(), $min, $max));
$progress = $this->create_progress_bar($max, $this->io, $this->output, true);
- $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING_START', preg_replace('(^text_reparser\\.)', '', $name)));
+ $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING_START', $reparser->get_name()));
$progress->start();
// Start from $max and decrement $current by $size until we reach $min
@@ -231,7 +227,7 @@ class reparse extends \phpbb\console\command\command
$start = max($min, $current + 1 - $size);
$end = max($min, $current);
- $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', preg_replace('(^text_reparser\\.)', '', $name), $start, $end));
+ $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', $reparser->get_name(), $start, $end));
$reparser->reparse_range($start, $end);
$current = $start - 1;
diff --git a/phpBB/phpbb/console/command/update/check.php b/phpBB/phpbb/console/command/update/check.php
new file mode 100644
index 0000000000..1f1cfa25d2
--- /dev/null
+++ b/phpBB/phpbb/console/command/update/check.php
@@ -0,0 +1,331 @@
+<?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\update;
+
+use phpbb\config\config;
+use phpbb\exception\exception_interface;
+use phpbb\language\language;
+use phpbb\user;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+class check extends \phpbb\console\command\command
+{
+ /** @var \phpbb\config\config */
+ protected $config;
+
+ /** @var \Symfony\Component\DependencyInjection\ContainerBuilder */
+ protected $phpbb_container;
+ /**
+ * @var language
+ */
+ private $language;
+
+ /**
+ * Construct method
+ */
+ public function __construct(user $user, config $config, ContainerInterface $phpbb_container, language $language)
+ {
+ $this->config = $config;
+ $this->phpbb_container = $phpbb_container;
+ $this->language = $language;
+
+ $this->language->add_lang(array('acp/common', 'acp/extensions'));
+
+ parent::__construct($user);
+ }
+
+ /**
+ * Configures the service.
+ *
+ * Sets the name and description of the command.
+ *
+ * @return null
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('update:check')
+ ->setDescription($this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK'))
+ ->addArgument('ext-name', InputArgument::OPTIONAL, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_ARGUMENT_1'))
+ ->addOption('stability', null, InputOption::VALUE_REQUIRED, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_OPTION_STABILITY'))
+ ->addOption('cache', 'c', InputOption::VALUE_NONE, $this->language->lang('CLI_DESCRIPTION_UPDATE_CHECK_OPTION_CACHE'))
+ ;
+ }
+
+ /**
+ * Executes the command.
+ *
+ * Checks if an update is available.
+ * If at least one is available, a message is printed and if verbose mode is set the list of possible updates is printed.
+ * If their is none, nothing is printed unless verbose mode is set.
+ *
+ * @param InputInterface $input Input stream, used to get the options.
+ * @param OutputInterface $output Output stream, used to print messages.
+ * @return int 0 if the board is up to date, 1 if it is not and 2 if an error occured.
+ * @throws \RuntimeException
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $io = new SymfonyStyle($input, $output);
+
+ $recheck = true;
+ if ($input->getOption('cache'))
+ {
+ $recheck = false;
+ }
+
+ $stability = null;
+ if ($input->getOption('stability'))
+ {
+ $stability = $input->getOption('stability');
+ if (!($stability == 'stable') && !($stability == 'unstable'))
+ {
+ $io->error($this->language->lang('CLI_ERROR_INVALID_STABILITY', $stability));
+ return 3;
+ }
+ }
+
+ $ext_name = $input->getArgument('ext-name');
+ if ($ext_name != null)
+ {
+ if ($ext_name == 'all')
+ {
+ return $this->check_all_ext($io, $stability, $recheck);
+ }
+ else
+ {
+ return $this->check_ext($input, $io, $stability, $recheck, $ext_name);
+ }
+ }
+ else
+ {
+ return $this->check_core($input, $io, $stability, $recheck);
+ }
+ }
+
+ /**
+ * Check if a given extension is up to date
+ *
+ * @param InputInterface $input Input stream, used to get the options.
+ * @param SymfonyStyle $io IO handler, for formatted and unified IO
+ * @param string $stability Force a given stability
+ * @param bool $recheck Disallow the use of the cache
+ * @param string $ext_name The extension name
+ * @return int
+ */
+ protected function check_ext(InputInterface $input, SymfonyStyle $io, $stability, $recheck, $ext_name)
+ {
+ try
+ {
+ $ext_manager = $this->phpbb_container->get('ext.manager');
+ $md_manager = $ext_manager->create_extension_metadata_manager($ext_name, null);
+ $updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability);
+
+ $metadata = $md_manager->get_metadata('all');
+ if ($input->getOption('verbose'))
+ {
+ $io->title($md_manager->get_metadata('display-name'));
+
+ $io->note($this->language->lang('CURRENT_VERSION') . $this->language->lang('COLON') . ' ' . $metadata['version']);
+ }
+
+ if (!empty($updates_available))
+ {
+ if ($input->getOption('verbose'))
+ {
+ $io->caution($this->language->lang('NOT_UP_TO_DATE', $metadata['name']));
+
+ $this->display_versions($io, $updates_available);
+ }
+
+ return 1;
+ }
+ else
+ {
+ if ($input->getOption('verbose'))
+ {
+ $io->success($this->language->lang('UPDATE_NOT_NEEDED'));
+ }
+
+ return 0;
+ }
+ }
+ catch (\RuntimeException $e)
+ {
+ $io->error($this->language->lang('EXTENSION_NOT_INSTALLED', $ext_name));
+
+ return 1;
+ }
+ }
+
+ /**
+ * Check if the core is up to date
+ *
+ * @param InputInterface $input Input stream, used to get the options.
+ * @param SymfonyStyle $io IO handler, for formatted and unified IO
+ * @param string $stability Force a given stability
+ * @param bool $recheck Disallow the use of the cache
+ * @return int
+ */
+ protected function check_core(InputInterface $input, SymfonyStyle $io, $stability, $recheck)
+ {
+ $version_helper = $this->phpbb_container->get('version_helper');
+ $version_helper->force_stability($stability);
+
+ $updates_available = $version_helper->get_suggested_updates($recheck);
+
+ if ($input->getOption('verbose'))
+ {
+ $io->title('phpBB core');
+
+ $io->note( $this->language->lang('CURRENT_VERSION') . $this->language->lang('COLON') . ' ' . $this->config['version']);
+ }
+
+ if (!empty($updates_available))
+ {
+ $io->caution($this->language->lang('UPDATE_NEEDED'));
+
+ if ($input->getOption('verbose'))
+ {
+ $this->display_versions($io, $updates_available);
+ }
+
+ return 1;
+ }
+ else
+ {
+ if ($input->getOption('verbose'))
+ {
+ $io->success($this->language->lang('UPDATE_NOT_NEEDED'));
+ }
+
+ return 0;
+ }
+ }
+
+ /**
+ * Check if all the available extensions are up to date
+ *
+ * @param SymfonyStyle $io IO handler, for formatted and unified IO
+ * @param bool $recheck Disallow the use of the cache
+ * @return int
+ */
+ protected function check_all_ext(SymfonyStyle $io, $stability, $recheck)
+ {
+ /** @var \phpbb\extension\manager $ext_manager */
+ $ext_manager = $this->phpbb_container->get('ext.manager');
+
+ $rows = [];
+
+ foreach ($ext_manager->all_available() as $ext_name => $ext_path)
+ {
+ $row = [];
+ $row[] = sprintf("<info>%s</info>", $ext_name);
+ $md_manager = $ext_manager->create_extension_metadata_manager($ext_name);
+ try
+ {
+ $metadata = $md_manager->get_metadata('all');
+ if (isset($metadata['extra']['version-check']))
+ {
+ try {
+ $updates_available = $ext_manager->version_check($md_manager, $recheck, false, $stability);
+ if (!empty($updates_available))
+ {
+ $versions = array_map(function($entry)
+ {
+ return $entry['current'];
+ }, $updates_available);
+
+ $row[] = sprintf("<comment>%s</comment>", $metadata['version']);
+ $row[] = implode(', ', $versions);
+ }
+ else
+ {
+ $row[] = sprintf("<info>%s</info>", $metadata['version']);
+ $row[] = '';
+ }
+ } catch (\RuntimeException $e) {
+ $row[] = $metadata['version'];
+ $row[] = '';
+ }
+ }
+ else
+ {
+ $row[] = $metadata['version'];
+ $row[] = '';
+ }
+ }
+ catch (exception_interface $e)
+ {
+ $exception_message = call_user_func_array(array($this->user, 'lang'), array_merge(array($e->getMessage()), $e->get_parameters()));
+ $row[] = '<error>' . $exception_message . '</error>';
+ }
+ catch (\RuntimeException $e)
+ {
+ $row[] = '<error>' . $e->getMessage() . '</error>';
+ }
+
+ $rows[] = $row;
+ }
+
+ $io->table([
+ $this->language->lang('EXTENSION_NAME'),
+ $this->language->lang('CURRENT_VERSION'),
+ $this->language->lang('LATEST_VERSION'),
+ ], $rows);
+
+ return 0;
+ }
+
+ /**
+ * Display the details of the available updates
+ *
+ * @param SymfonyStyle $io IO handler, for formatted and unified IO
+ * @param array $updates_available The list of the available updates
+ */
+ protected function display_versions(SymfonyStyle $io, $updates_available)
+ {
+ $io->section($this->language->lang('UPDATES_AVAILABLE'));
+
+ $rows = [];
+ foreach ($updates_available as $version_data)
+ {
+ $row = ['', '', ''];
+ $row[0] = $version_data['current'];
+
+ if (isset($version_data['announcement']))
+ {
+ $row[1] = $version_data['announcement'];
+ }
+
+ if (isset($version_data['download']))
+ {
+ $row[2] = $version_data['download'];
+ }
+
+ $rows[] = $row;
+ }
+
+ $io->table([
+ $this->language->lang('VERSION'),
+ $this->language->lang('ANNOUNCEMENT_TOPIC'),
+ $this->language->lang('DOWNLOAD_LATEST'),
+ ], $rows);
+ }
+}