1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-24 20:13:22 +01:00

[ticket/13891] Added command-line options

PHPBB3-13891
This commit is contained in:
JoshyPHP 2015-06-29 23:05:52 +02:00
parent 119f90e363
commit fadb192c57
2 changed files with 37 additions and 9 deletions

View File

@ -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 options value only if the old matches the current value',
'CLI_DESCRIPTION_SET_CONFIG' => 'Sets a configuration options value',

View File

@ -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;
}
}
}