[ticket/12683] Fix create index command

PHPBB3-12683
This commit is contained in:
rubencm 2021-03-24 19:13:56 +01:00 committed by Ruben Calvo
parent 0a24704b4f
commit 75bdbcf4fe
No known key found for this signature in database
4 changed files with 9 additions and 7 deletions

View file

@ -90,6 +90,8 @@ class create extends command
{ {
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
$io->section($this->language->lang('CLI_DESCRIPTION_SEARCHINDEX_CREATE'));
$search_backend = $input->getArgument('search-backend'); $search_backend = $input->getArgument('search-backend');
try try
@ -105,18 +107,16 @@ class create extends command
try try
{ {
$counter = 0;
$progress = $this->create_progress_bar(1, $io, $output, true); $progress = $this->create_progress_bar(1, $io, $output, true);
$progress->setMessage('');
$progress->start(); $progress->start();
$counter = 0;
while (($status = $search->create_index($counter)) !== null) while (($status = $search->create_index($counter)) !== null)
{ {
$progress->setMaxSteps($status['max_post_id']); $progress->setMaxSteps($status['max_post_id']);
$progress->setProgress($status['post_counter']); $progress->setProgress($status['post_counter']);
$progress->setMessage(round($status['rows_per_second'], 2) . ' rows/s'); $progress->setMessage(round($status['rows_per_second'], 2) . ' rows/s');
$progress->advance();
} }
$progress->finish(); $progress->finish();

View file

@ -391,7 +391,9 @@ abstract class base implements search_backend_interface
$starttime = microtime(true); $starttime = microtime(true);
$row_count = 0; $row_count = 0;
while (still_on_time() && $post_counter <= $max_post_id)
$still_on_time = PHP_SAPI === 'cli' ? true : still_on_time();
while ($still_on_time && $post_counter <= $max_post_id)
{ {
$rows = $this->get_posts_batch_after($post_counter); $rows = $this->get_posts_batch_after($post_counter);
$ids = $posters = $forum_ids = array(); $ids = $posters = $forum_ids = array();