diff options
author | JoshyPHP <s9e.dev@gmail.com> | 2015-06-29 23:05:52 +0200 |
---|---|---|
committer | JoshyPHP <s9e.dev@gmail.com> | 2015-06-30 10:32:00 +0200 |
commit | fadb192c570db25fe4b36b1b3803fb923e6f9d4e (patch) | |
tree | fd54de73c61cd309f6f9bad643009f86cc9158a4 /phpBB | |
parent | 119f90e36301463ffd01005a9390d3346be7774f (diff) | |
download | forums-fadb192c570db25fe4b36b1b3803fb923e6f9d4e.tar forums-fadb192c570db25fe4b36b1b3803fb923e6f9d4e.tar.gz forums-fadb192c570db25fe4b36b1b3803fb923e6f9d4e.tar.bz2 forums-fadb192c570db25fe4b36b1b3803fb923e6f9d4e.tar.xz forums-fadb192c570db25fe4b36b1b3803fb923e6f9d4e.zip |
[ticket/13891] Added command-line options
PHPBB3-13891
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/language/en/cli.php | 3 | ||||
-rw-r--r-- | phpBB/phpbb/console/command/reparser/reparse.php | 43 |
2 files changed, 37 insertions, 9 deletions
diff --git a/phpBB/language/en/cli.php b/phpBB/language/en/cli.php index bbcc736143..c301f98261 100644 --- a/phpBB/language/en/cli.php +++ b/phpBB/language/en/cli.php @@ -64,6 +64,9 @@ $lang = array_merge($lang, array( 'CLI_DESCRIPTION_REPARSER_LIST' => 'Lists the types of text that can be reparsed.', 'CLI_DESCRIPTION_REPARSER_REPARSE' => 'Reparses stored text with the current text_formatter services.', 'CLI_DESCRIPTION_REPARSER_REPARSE_ARG_1' => 'Type of text to reparse. Leave blank to reparse everything.', + 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MIN' => 'Lowest record ID to process', + 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MAX' => 'Highest record ID to process', + 'CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_SIZE' => 'Approximate number of records to process at a time', 'CLI_DESCRIPTION_RECALCULATE_EMAIL_HASH' => 'Recalculates the user_email_hash column of the users table.', 'CLI_DESCRIPTION_SET_ATOMIC_CONFIG' => 'Sets a configuration option’s value only if the old matches the current value', 'CLI_DESCRIPTION_SET_CONFIG' => 'Sets a configuration option’s value', diff --git a/phpBB/phpbb/console/command/reparser/reparse.php b/phpBB/phpbb/console/command/reparser/reparse.php index 8cefee837f..5e1993d44c 100644 --- a/phpBB/phpbb/console/command/reparser/reparse.php +++ b/phpBB/phpbb/console/command/reparser/reparse.php @@ -15,6 +15,7 @@ namespace phpbb\console\command\reparser; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class reparse extends \phpbb\console\command\command @@ -49,6 +50,26 @@ class reparse extends \phpbb\console\command\command ->setName('reparser:reparse') ->setDescription($this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE')) ->addArgument('reparser-name', InputArgument::OPTIONAL, $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_ARG_1')) + ->addOption( + 'range-min', + null, + InputOption::VALUE_REQUIRED, + $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MIN'), + 0 + ) + ->addOption( + 'range-max', + null, + InputOption::VALUE_REQUIRED, + $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MAX') + ) + ->addOption( + 'range-size', + null, + InputOption::VALUE_REQUIRED, + $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_SIZE'), + 100 + ); ; } @@ -69,13 +90,13 @@ class reparse extends \phpbb\console\command\command { $name = 'text_reparser.' . $name; } - $this->reparse($output, $name); + $this->reparse($input, $output, $name); } else { foreach ($this->reparsers as $name => $service) { - $this->reparse($output, $name); + $this->reparse($input, $output, $name); } } @@ -83,24 +104,28 @@ class reparse extends \phpbb\console\command\command } /** - * Reparse all text handled by given reparser + * Reparse all text handled by given reparser within given range * + * @param InputInterface $input * @param OutputInterface $output * @param string $name Reparser name * @return null */ - protected function reparse(OutputInterface $output, $name) + protected function reparse(InputInterface $input, OutputInterface $output, $name) { $reparser = $this->reparsers[$name]; - $id = $reparser->get_max_id(); - $n = 100; - while ($id > 0) + + // Start at range-max if specified or at the highest ID otherwise + $id = (is_null($input->getOption('range-max'))) ? $reparser->get_max_id() : $input->getOption('range-max'); + $min = $input->getOption('range-min'); + $size = $input->getOption('range-size'); + while ($id > $min) { - $start = max(0, $id + 1 - $n); + $start = max($min, $id + 1 - $size); $end = $id; $output->writeln('<info>' . $this->user->lang('CLI_REPARSER_REPARSE_REPARSING', $name, $start, $end) . '</info>'); $reparser->reparse_range($start, $end); - $id -= $n; + $id -= $size; } } } |