aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/console
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/console')
-rw-r--r--phpBB/phpbb/console/application.php120
-rw-r--r--phpBB/phpbb/console/command/cache/purge.php89
-rw-r--r--phpBB/phpbb/console/command/command.php31
-rw-r--r--phpBB/phpbb/console/command/config/command.php26
-rw-r--r--phpBB/phpbb/console/command/config/delete.php63
-rw-r--r--phpBB/phpbb/console/command/config/get.php72
-rw-r--r--phpBB/phpbb/console/command/config/increment.php70
-rw-r--r--phpBB/phpbb/console/command/config/set.php70
-rw-r--r--phpBB/phpbb/console/command/config/set_atomic.php84
-rw-r--r--phpBB/phpbb/console/command/cron/cron_list.php111
-rw-r--r--phpBB/phpbb/console/command/cron/run.php171
-rw-r--r--phpBB/phpbb/console/command/db/console_migrator_output_handler.php69
-rw-r--r--phpBB/phpbb/console/command/db/migrate.php107
-rw-r--r--phpBB/phpbb/console/command/dev/migration_tips.php64
-rw-r--r--phpBB/phpbb/console/command/extension/command.php30
-rw-r--r--phpBB/phpbb/console/command/extension/disable.php52
-rw-r--r--phpBB/phpbb/console/command/extension/enable.php52
-rw-r--r--phpBB/phpbb/console/command/extension/purge.php52
-rw-r--r--phpBB/phpbb/console/command/extension/show.php62
-rw-r--r--phpBB/phpbb/console/command/fixup/recalculate_email_hash.php75
20 files changed, 1470 insertions, 0 deletions
diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php
new file mode 100644
index 0000000000..bc4897af18
--- /dev/null
+++ b/phpBB/phpbb/console/application.php
@@ -0,0 +1,120 @@
+<?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;
+
+use Symfony\Component\Console\Shell;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class application extends \Symfony\Component\Console\Application
+{
+ /**
+ * @var bool Indicates whether or not we are in a shell
+ */
+ protected $in_shell = false;
+
+ /**
+ * @var \phpbb\user User object
+ */
+ protected $user;
+
+ /**
+ * @param string $name The name of the application
+ * @param string $version The version of the application
+ * @param \phpbb\user $user The user which runs the application (used for translation)
+ */
+ public function __construct($name, $version, \phpbb\user $user)
+ {
+ $this->user = $user;
+
+ parent::__construct($name, $version);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getDefaultInputDefinition()
+ {
+ $input_definition = parent::getDefaultInputDefinition();
+
+ $input_definition->addOption(new InputOption(
+ 'safe-mode',
+ null,
+ InputOption::VALUE_NONE,
+ $this->user->lang('CLI_DESCRIPTION_OPTION_SAFE_MODE')
+ ));
+
+ return $input_definition;
+ }
+
+ /**
+ * Gets the help message.
+ *
+ * It's a hack of the default help message to display the --shell
+ * option only for the application and not for all the commands.
+ *
+ * @return string A help message.
+ */
+ public function getHelp()
+ {
+ // If we are already in a shell
+ // we do not want to have the --shell option available
+ if ($this->in_shell)
+ {
+ return parent::getHelp();
+ }
+
+ $this->getDefinition()->addOption(new InputOption(
+ '--shell',
+ '-s',
+ InputOption::VALUE_NONE,
+ $this->user->lang('CLI_DESCRIPTION_OPTION_SHELL')
+ ));
+
+ return parent::getHelp();
+ }
+
+ /**
+ * Register a set of commands from the container
+ *
+ * @param \phpbb\di\service_collection $command_collection The console service collection
+ */
+ public function register_container_commands(\phpbb\di\service_collection $command_collection)
+ {
+ foreach ($command_collection as $service_command)
+ {
+ $this->add($service_command);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function doRun(InputInterface $input, OutputInterface $output)
+ {
+ // Run a shell if the --shell (or -s) option is set and if no command name is specified
+ // Also, we do not want to have the --shell option available if we are already in a shell
+ if (!$this->in_shell && $this->getCommandName($input) === null && $input->hasParameterOption(array('--shell', '-s')))
+ {
+ $shell = new Shell($this);
+ $this->in_shell = true;
+ $shell->run();
+
+ return 0;
+ }
+
+ return parent::doRun($input, $output);
+ }
+}
diff --git a/phpBB/phpbb/console/command/cache/purge.php b/phpBB/phpbb/console/command/cache/purge.php
new file mode 100644
index 0000000000..d0c2ef6f72
--- /dev/null
+++ b/phpBB/phpbb/console/command/cache/purge.php
@@ -0,0 +1,89 @@
+<?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\cache;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class purge extends \phpbb\console\command\command
+{
+ /** @var \phpbb\cache\driver\driver_interface */
+ protected $cache;
+
+ /** @var \phpbb\db\driver\driver_interface */
+ protected $db;
+
+ /** @var \phpbb\auth\auth */
+ protected $auth;
+
+ /** @var \phpbb\log\log_interface */
+ protected $log;
+
+ /** @var \phpbb\config\config */
+ protected $config;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\user $user User instance
+ * @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\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)
+ {
+ $this->cache = $cache;
+ $this->db = $db;
+ $this->auth = $auth;
+ $this->log = $log;
+ $this->config = $config;
+ parent::__construct($user);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('cache:purge')
+ ->setDescription($this->user->lang('PURGE_CACHE'))
+ ;
+ }
+
+ /**
+ * Executes the command cache:purge.
+ *
+ * Purge the cache (including permissions) and increment the asset_version number
+ *
+ * @param InputInterface $input An InputInterface instance
+ * @param OutputInterface $output An OutputInterface instance
+ *
+ * @return null
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $this->config->increment('assets_version', 1);
+ $this->cache->purge();
+
+ // Clear permissions
+ $this->auth->acl_clear_prefetch();
+ phpbb_cache_moderators($this->db, $this->cache, $this->auth);
+
+ $this->log->add('admin', ANONYMOUS, '', 'LOG_PURGE_CACHE', time(), array());
+
+ $output->writeln($this->user->lang('PURGE_CACHE_SUCCESS'));
+ }
+}
diff --git a/phpBB/phpbb/console/command/command.php b/phpBB/phpbb/console/command/command.php
new file mode 100644
index 0000000000..638c989da2
--- /dev/null
+++ b/phpBB/phpbb/console/command/command.php
@@ -0,0 +1,31 @@
+<?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;
+
+abstract class command extends \Symfony\Component\Console\Command\Command
+{
+ /** @var \phpbb\user */
+ protected $user;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\user $user User instance (mostly for translation)
+ */
+ public function __construct(\phpbb\user $user)
+ {
+ $this->user = $user;
+ parent::__construct();
+ }
+}
diff --git a/phpBB/phpbb/console/command/config/command.php b/phpBB/phpbb/console/command/config/command.php
new file mode 100644
index 0000000000..f0ad5d4d19
--- /dev/null
+++ b/phpBB/phpbb/console/command/config/command.php
@@ -0,0 +1,26 @@
+<?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\config;
+
+abstract class command extends \phpbb\console\command\command
+{
+ /** @var \phpbb\config\config */
+ protected $config;
+
+ function __construct(\phpbb\user $user, \phpbb\config\config $config)
+ {
+ $this->config = $config;
+
+ parent::__construct($user);
+ }
+}
diff --git a/phpBB/phpbb/console/command/config/delete.php b/phpBB/phpbb/console/command/config/delete.php
new file mode 100644
index 0000000000..efd276d7e3
--- /dev/null
+++ b/phpBB/phpbb/console/command/config/delete.php
@@ -0,0 +1,63 @@
+<?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\config;
+
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class delete extends command
+{
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('config:delete')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_DELETE_CONFIG'))
+ ->addArgument(
+ 'key',
+ InputArgument::REQUIRED,
+ $this->user->lang('CLI_CONFIG_OPTION_NAME')
+ )
+ ;
+ }
+
+ /**
+ * Executes the command config:delete.
+ *
+ * Removes a configuration option
+ *
+ * @param InputInterface $input An InputInterface instance
+ * @param OutputInterface $output An OutputInterface instance
+ *
+ * @return null
+ * @see \phpbb\config\config::delete()
+ */
+ protected function execute(InputInterface $input, OutputInterface $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>');
+ }
+ else
+ {
+ $output->writeln('<error>' . $this->user->lang('CLI_CONFIG_NOT_EXISTS', $key) . '</error>');
+ }
+ }
+}
diff --git a/phpBB/phpbb/console/command/config/get.php b/phpBB/phpbb/console/command/config/get.php
new file mode 100644
index 0000000000..9c03b49a3d
--- /dev/null
+++ b/phpBB/phpbb/console/command/config/get.php
@@ -0,0 +1,72 @@
+<?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\config;
+
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class get extends command
+{
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('config:get')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_GET_CONFIG'))
+ ->addArgument(
+ 'key',
+ InputArgument::REQUIRED,
+ $this->user->lang('CLI_CONFIG_OPTION_NAME')
+ )
+ ->addOption(
+ 'no-newline',
+ null,
+ InputOption::VALUE_NONE,
+ $this->user->lang('CLI_CONFIG_PRINT_WITHOUT_NEWLINE')
+ )
+ ;
+ }
+
+ /**
+ * Executes the command config:get.
+ *
+ * Retrieves a configuration value.
+ *
+ * @param InputInterface $input An InputInterface instance
+ * @param OutputInterface $output An OutputInterface instance
+ *
+ * @return null
+ * @see \phpbb\config\config::offsetGet()
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $key = $input->getArgument('key');
+
+ if (isset($this->config[$key]) && $input->getOption('no-newline'))
+ {
+ $output->write($this->config[$key]);
+ }
+ else if (isset($this->config[$key]))
+ {
+ $output->writeln($this->config[$key]);
+ }
+ else
+ {
+ $output->writeln('<error>' . $this->user->lang('CLI_CONFIG_NOT_EXISTS', $key) . '</error>');
+ }
+ }
+}
diff --git a/phpBB/phpbb/console/command/config/increment.php b/phpBB/phpbb/console/command/config/increment.php
new file mode 100644
index 0000000000..b4d7438b66
--- /dev/null
+++ b/phpBB/phpbb/console/command/config/increment.php
@@ -0,0 +1,70 @@
+<?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\config;
+
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class increment extends command
+{
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('config:increment')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_INCREMENT_CONFIG'))
+ ->addArgument(
+ 'key',
+ InputArgument::REQUIRED,
+ $this->user->lang('CLI_CONFIG_OPTION_NAME')
+ )
+ ->addArgument(
+ 'increment',
+ InputArgument::REQUIRED,
+ $this->user->lang('CLI_CONFIG_INCREMENT_BY')
+ )
+ ->addOption(
+ 'dynamic',
+ 'd',
+ InputOption::VALUE_NONE,
+ $this->user->lang('CLI_CONFIG_CANNOT_CACHED')
+ )
+ ;
+ }
+
+ /**
+ * Executes the command config:increment.
+ *
+ * Increments an integer configuration value.
+ *
+ * @param InputInterface $input An InputInterface instance
+ * @param OutputInterface $output An OutputInterface instance
+ *
+ * @return null
+ * @see \phpbb\config\config::increment()
+ */
+ protected function execute(InputInterface $input, OutputInterface $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>');
+ }
+}
diff --git a/phpBB/phpbb/console/command/config/set.php b/phpBB/phpbb/console/command/config/set.php
new file mode 100644
index 0000000000..695de31013
--- /dev/null
+++ b/phpBB/phpbb/console/command/config/set.php
@@ -0,0 +1,70 @@
+<?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\config;
+
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class set extends command
+{
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('config:set')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_SET_CONFIG'))
+ ->addArgument(
+ 'key',
+ InputArgument::REQUIRED,
+ $this->user->lang('CLI_CONFIG_OPTION_NAME')
+ )
+ ->addArgument(
+ 'value',
+ InputArgument::REQUIRED,
+ $this->user->lang('CLI_CONFIG_NEW')
+ )
+ ->addOption(
+ 'dynamic',
+ 'd',
+ InputOption::VALUE_NONE,
+ $this->user->lang('CLI_CONFIG_CANNOT_CACHED')
+ )
+ ;
+ }
+
+ /**
+ * Executes the command config:set.
+ *
+ * Sets a configuration option's value.
+ *
+ * @param InputInterface $input An InputInterface instance
+ * @param OutputInterface $output An OutputInterface instance
+ *
+ * @return null
+ * @see \phpbb\config\config::set()
+ */
+ protected function execute(InputInterface $input, OutputInterface $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>');
+ }
+}
diff --git a/phpBB/phpbb/console/command/config/set_atomic.php b/phpBB/phpbb/console/command/config/set_atomic.php
new file mode 100644
index 0000000000..e8c69a0885
--- /dev/null
+++ b/phpBB/phpbb/console/command/config/set_atomic.php
@@ -0,0 +1,84 @@
+<?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\config;
+
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class set_atomic extends command
+{
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('config:set-atomic')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_SET_ATOMIC_CONFIG'))
+ ->addArgument(
+ 'key',
+ InputArgument::REQUIRED,
+ $this->user->lang('CLI_CONFIG_OPTION_NAME')
+ )
+ ->addArgument(
+ 'old',
+ InputArgument::REQUIRED,
+ $this->user->lang('CLI_CONFIG_CURRENT')
+ )
+ ->addArgument(
+ 'new',
+ InputArgument::REQUIRED,
+ $this->user->lang('CLI_CONFIG_NEW')
+ )
+ ->addOption(
+ 'dynamic',
+ 'd',
+ InputOption::VALUE_NONE,
+ $this->user->lang('CLI_CONFIG_CANNOT_CACHED')
+ )
+ ;
+ }
+
+ /**
+ * Executes the command config:set-atomic.
+ *
+ * Sets a configuration option's value only if the old_value matches the
+ * current configuration value or the configuration value does not exist yet.
+ *
+ * @param InputInterface $input An InputInterface instance
+ * @param OutputInterface $output An OutputInterface instance
+ *
+ * @return bool True if the value was changed, false otherwise.
+ * @see \phpbb\config\config::set_atomic()
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $key = $input->getArgument('key');
+ $old_value = $input->getArgument('old');
+ $new_value = $input->getArgument('new');
+ $use_cache = !$input->getOption('dynamic');
+
+ if ($this->config->set_atomic($key, $old_value, $new_value, $use_cache))
+ {
+ $output->writeln('<info>' . $this->user->lang('CLI_CONFIG_SET_SUCCESS', $key) . '</info>');
+ return 0;
+ }
+ else
+ {
+ $output->writeln('<error>' . $this->user->lang('CLI_CONFIG_SET_FAILURE', $key) . '</error>');
+ return 1;
+ }
+ }
+}
diff --git a/phpBB/phpbb/console/command/cron/cron_list.php b/phpBB/phpbb/console/command/cron/cron_list.php
new file mode 100644
index 0000000000..c515fd9e80
--- /dev/null
+++ b/phpBB/phpbb/console/command/cron/cron_list.php
@@ -0,0 +1,111 @@
+<?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\cron;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class cron_list extends \phpbb\console\command\command
+{
+ /** @var \phpbb\cron\manager */
+ protected $cron_manager;
+
+ /**
+ * Constructor
+ *
+ * @param \phpbb\user $user User instance
+ * @param \phpbb\cron\manager $cron_manager Cron manager
+ */
+ public function __construct(\phpbb\user $user, \phpbb\cron\manager $cron_manager)
+ {
+ $this->cron_manager = $cron_manager;
+ parent::__construct($user);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('cron:list')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_CRON_LIST'))
+ ;
+ }
+
+ /**
+ * Executes the command cron:list.
+ *
+ * Prints a list of ready and unready cron jobs.
+ *
+ * @param InputInterface $input An InputInterface instance
+ * @param OutputInterface $output An OutputInterface instance
+ *
+ * @return null
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $tasks = $this->cron_manager->get_tasks();
+
+ if (empty($tasks))
+ {
+ $output->writeln($this->user->lang('CRON_NO_TASKS'));
+ return;
+ }
+
+ $ready_tasks = array();
+ $not_ready_tasks = array();
+ foreach ($tasks as $task)
+ {
+ if ($task->is_ready())
+ {
+ $ready_tasks[] = $task;
+ }
+ else
+ {
+ $not_ready_tasks[] = $task;
+ }
+ }
+
+ 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('');
+ }
+
+ 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());
+ }
+ }
+}
diff --git a/phpBB/phpbb/console/command/cron/run.php b/phpBB/phpbb/console/command/cron/run.php
new file mode 100644
index 0000000000..72ad1205ef
--- /dev/null
+++ b/phpBB/phpbb/console/command/cron/run.php
@@ -0,0 +1,171 @@
+<?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\cron;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class run extends \phpbb\console\command\command
+{
+ /** @var \phpbb\cron\manager */
+ protected $cron_manager;
+
+ /** @var \phpbb\lock\db */
+ protected $lock_db;
+
+ /**
+ * Construct method
+ *
+ * @param \phpbb\user $user The user object (used to get language information)
+ * @param \phpbb\cron\manager $cron_manager The cron manager containing
+ * the cron tasks to be executed.
+ * @param \phpbb\lock\db $lock_db The lock for accessing database.
+ */
+ public function __construct(\phpbb\user $user, \phpbb\cron\manager $cron_manager, \phpbb\lock\db $lock_db)
+ {
+ $this->cron_manager = $cron_manager;
+ $this->lock_db = $lock_db;
+ parent::__construct($user);
+ }
+
+ /**
+ * Sets the command name and description
+ *
+ * @return null
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('cron:run')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_CRON_RUN'))
+ ->addArgument('name', InputArgument::OPTIONAL, $this->user->lang('CLI_DESCRIPTION_CRON_RUN_ARGUMENT_1'))
+ ;
+ }
+
+ /**
+ * Executes the command cron:run.
+ *
+ * Tries to acquire the cron lock, then if no argument has been given runs all ready cron tasks.
+ * If the cron lock can not be obtained, an error message is printed
+ * and the exit status is set to 1.
+ * If the verbose option is specified, each start of a task is printed.
+ * Otherwise there is no output.
+ * If an argument is given to the command, only the task whose name matches the
+ * argument will be started. If verbose option is specified,
+ * an info message containing the name of the task is printed.
+ * If no task matches the argument given, an error message is printed
+ * and the exit status is set to 2.
+ *
+ * @param InputInterface $input The input stream used to get the argument and verboe option.
+ * @param OutputInterface $output The output stream, used for printing verbose-mode and error information.
+ *
+ * @return int 0 if all is ok, 1 if a lock error occured and 2 if no task matching the argument was found.
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ if ($this->lock_db->acquire())
+ {
+ $task_name = $input->getArgument('name');
+ if ($task_name)
+ {
+ $exit_status = $this->run_one($input, $output, $task_name);
+ }
+ else
+ {
+ $exit_status = $this->run_all($input, $output);
+ }
+
+ $this->lock_db->release();
+ return $exit_status;
+ }
+ else
+ {
+ $output->writeln('<error>' . $this->user->lang('CRON_LOCK_ERROR') . '</error>');
+ return 1;
+ }
+ }
+
+ /**
+ * Executes all ready cron tasks.
+ *
+ * If verbose mode is set, an info message will be printed if there is no task to
+ * be run, or else for each starting task.
+ *
+ * @see execute
+ * @param InputInterface $input The input stream used to get the argument and verbose option.
+ * @param OutputInterface $output The output stream, used for printing verbose-mode and error information.
+ * @return int 0
+ */
+ protected function run_all(InputInterface $input, OutputInterface $output)
+ {
+ $run_tasks = $this->cron_manager->find_all_ready_tasks();
+
+ if ($run_tasks)
+ {
+ foreach ($run_tasks as $task)
+ {
+ if ($input->getOption('verbose'))
+ {
+ $output->writeln('<info>' . $this->user->lang('RUNNING_TASK', $task->get_name()) . '</info>');
+ }
+
+ $task->run();
+ }
+ }
+ else
+ {
+ if ($input->getOption('verbose'))
+ {
+ $output->writeln('<info>' . $this->user->lang('CRON_NO_TASK') . '</info>');
+ }
+ }
+
+ return 0;
+ }
+
+ /**
+ * Executes a given cron task, if it is ready.
+ *
+ * If there is a task whose name matches $task_name, it is run and 0 is returned.
+ * and if verbose mode is set, print an info message with the name of the task.
+ * If there is no task matching $task_name, the function prints an error message
+ * and returns with status 2.
+ *
+ * @see execute
+ * @param string $task_name The name of the task that should be run.
+ * @param InputInterface $input The input stream used to get the argument and verbose option.
+ * @param OutputInterface $output The output stream, used for printing verbose-mode and error information.
+ * @return int 0 if all is well, 2 if no task matches $task_name.
+ */
+ protected function run_one(InputInterface $input, OutputInterface $output, $task_name)
+ {
+ $task = $this->cron_manager->find_task($task_name);
+ if ($task)
+ {
+ if ($input->getOption('verbose'))
+ {
+ $output->writeln('<info>' . $this->user->lang('RUNNING_TASK', $task_name) . '</info>');
+ }
+
+ $task->run();
+ return 0;
+ }
+ else
+ {
+ $output->writeln('<error>' . $this->user->lang('CRON_NO_SUCH_TASK', $task_name) . '</error>');
+ return 2;
+ }
+ }
+}
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
new file mode 100644
index 0000000000..87c2a057d1
--- /dev/null
+++ b/phpBB/phpbb/console/command/db/migrate.php
@@ -0,0 +1,107 @@
+<?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 Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class migrate extends \phpbb\console\command\command
+{
+ /** @var \phpbb\db\migrator */
+ protected $migrator;
+
+ /** @var \phpbb\extension\manager */
+ protected $extension_manager;
+
+ /** @var \phpbb\config\config */
+ protected $config;
+
+ /** @var \phpbb\cache\service */
+ protected $cache;
+
+ /** @var \phpbb\log\log */
+ protected $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'));
+ }
+
+ protected function configure()
+ {
+ $this
+ ->setName('db:migrate')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_DB_MIGRATE'))
+ ;
+ }
+
+ 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();
+
+ $this->load_migrations();
+ $orig_version = $this->config['version'];
+ while (!$this->migrator->finished())
+ {
+ try
+ {
+ $this->migrator->update();
+ }
+ catch (\phpbb\db\migration\exception $e)
+ {
+ $output->writeln('<error>' . $e->getLocalisedMessage($this->user) . '</error>');
+ $this->finalise_update();
+ return 1;
+ }
+ }
+
+ if ($orig_version != $this->config['version'])
+ {
+ $this->log->add('admin', ANONYMOUS, '', 'LOG_UPDATE_DATABASE', time(), array($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/')
+ ->extension_directory('/migrations')
+ ->get_classes();
+
+ $this->migrator->set_migrations($migrations);
+ }
+
+ protected function finalise_update()
+ {
+ $this->cache->purge();
+ $this->config->increment('assets_version', 1);
+ }
+}
diff --git a/phpBB/phpbb/console/command/dev/migration_tips.php b/phpBB/phpbb/console/command/dev/migration_tips.php
new file mode 100644
index 0000000000..f9047bdac8
--- /dev/null
+++ b/phpBB/phpbb/console/command/dev/migration_tips.php
@@ -0,0 +1,64 @@
+<?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\dev;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+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)
+ {
+ $this->extension_manager = $extension_manager;
+ parent::__construct($user);
+ }
+
+ protected function configure()
+ {
+ $this
+ ->setName('dev:migration-tips')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_FIND_MIGRATIONS'))
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $migrations = $this->extension_manager->get_finder()
+ ->set_extensions(array())
+ ->core_path('phpbb/db/migration/data/')
+ ->get_classes();
+ $tips = $migrations;
+
+ foreach ($migrations as $migration_class)
+ {
+ foreach ($migration_class::depends_on() as $dependency)
+ {
+ $tips_key = array_search($dependency, $tips);
+ if ($tips_key !== false)
+ {
+ unset($tips[$tips_key]);
+ }
+ }
+ }
+
+ $output->writeln("\t\tarray(");
+ foreach ($tips as $migration)
+ {
+ $output->writeln("\t\t\t'{$migration}',");
+ }
+ $output->writeln("\t\t);");
+ }
+}
diff --git a/phpBB/phpbb/console/command/extension/command.php b/phpBB/phpbb/console/command/extension/command.php
new file mode 100644
index 0000000000..364d954082
--- /dev/null
+++ b/phpBB/phpbb/console/command/extension/command.php
@@ -0,0 +1,30 @@
+<?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\extension;
+
+abstract class command extends \phpbb\console\command\command
+{
+ /** @var \phpbb\extension\manager */
+ protected $manager;
+
+ /** @var \phpbb\log\log */
+ protected $log;
+
+ public function __construct(\phpbb\user $user, \phpbb\extension\manager $manager, \phpbb\log\log $log)
+ {
+ $this->manager = $manager;
+ $this->log = $log;
+
+ parent::__construct($user);
+ }
+}
diff --git a/phpBB/phpbb/console/command/extension/disable.php b/phpBB/phpbb/console/command/extension/disable.php
new file mode 100644
index 0000000000..1eee16cbd9
--- /dev/null
+++ b/phpBB/phpbb/console/command/extension/disable.php
@@ -0,0 +1,52 @@
+<?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\extension;
+
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class disable extends command
+{
+ protected function configure()
+ {
+ $this
+ ->setName('extension:disable')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_DISABLE_EXTENSION'))
+ ->addArgument(
+ 'extension-name',
+ InputArgument::REQUIRED,
+ $this->user->lang('CLI_EXTENSION_NAME')
+ )
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $name = $input->getArgument('extension-name');
+ $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>');
+ 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>');
+ return 0;
+ }
+ }
+}
diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php
new file mode 100644
index 0000000000..59ff11e9b7
--- /dev/null
+++ b/phpBB/phpbb/console/command/extension/enable.php
@@ -0,0 +1,52 @@
+<?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\extension;
+
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class enable extends command
+{
+ protected function configure()
+ {
+ $this
+ ->setName('extension:enable')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_ENABLE_EXTENSION'))
+ ->addArgument(
+ 'extension-name',
+ InputArgument::REQUIRED,
+ $this->user->lang('CLI_EXTENSION_NAME')
+ )
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $name = $input->getArgument('extension-name');
+ $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>');
+ return 0;
+ }
+ else
+ {
+ $output->writeln('<error>' . $this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name) . '</error>');
+ return 1;
+ }
+ }
+}
diff --git a/phpBB/phpbb/console/command/extension/purge.php b/phpBB/phpbb/console/command/extension/purge.php
new file mode 100644
index 0000000000..517e9a74c9
--- /dev/null
+++ b/phpBB/phpbb/console/command/extension/purge.php
@@ -0,0 +1,52 @@
+<?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\extension;
+
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class purge extends command
+{
+ protected function configure()
+ {
+ $this
+ ->setName('extension:purge')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_PURGE_EXTENSION'))
+ ->addArgument(
+ 'extension-name',
+ InputArgument::REQUIRED,
+ $this->user->lang('CLI_EXTENSION_NAME')
+ )
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $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>');
+ 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>');
+ return 0;
+ }
+ }
+}
diff --git a/phpBB/phpbb/console/command/extension/show.php b/phpBB/phpbb/console/command/extension/show.php
new file mode 100644
index 0000000000..f9322034d7
--- /dev/null
+++ b/phpBB/phpbb/console/command/extension/show.php
@@ -0,0 +1,62 @@
+<?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\extension;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class show extends command
+{
+ protected function configure()
+ {
+ $this
+ ->setName('extension:show')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_LIST_EXTENSIONS'))
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $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>');
+ 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('');
+
+ $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('');
+
+ $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");
+ }
+ }
+}
diff --git a/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php b/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php
new file mode 100644
index 0000000000..ec4e1b0ee7
--- /dev/null
+++ b/phpBB/phpbb/console/command/fixup/recalculate_email_hash.php
@@ -0,0 +1,75 @@
+<?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\fixup;
+
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+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)
+ {
+ $this->db = $db;
+
+ parent::__construct($user);
+ }
+
+ protected function configure()
+ {
+ $this
+ ->setName('fixup:recalculate-email-hash')
+ ->setDescription($this->user->lang('CLI_DESCRIPTION_RECALCULATE_EMAIL_HASH'))
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $sql = 'SELECT user_id, user_email, user_email_hash
+ FROM ' . USERS_TABLE . '
+ WHERE user_type <> ' . USER_IGNORE . "
+ AND user_email <> ''";
+ $result = $this->db->sql_query($sql);
+
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $user_email_hash = phpbb_email_hash($row['user_email']);
+ if ($user_email_hash !== $row['user_email_hash'])
+ {
+ $sql_ary = array(
+ 'user_email_hash' => $user_email_hash,
+ );
+
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
+ WHERE user_id = ' . (int) $row['user_id'];
+ $this->db->sql_query($sql);
+
+ if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG)
+ {
+ $output->writeln(sprintf(
+ 'user_id %d, email %s => %s',
+ $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>');
+ }
+}