mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
[ticket/12683] Add progress bar to delete index
PHPBB3-12683
This commit is contained in:
@@ -86,7 +86,7 @@ class create extends command
|
||||
*
|
||||
* @return int 0 if all is well, 1 if any errors occurred
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
|
@@ -86,10 +86,12 @@ class delete extends command
|
||||
*
|
||||
* @return int 0 if all is well, 1 if any errors occurred
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$io->section($this->language->lang('CLI_DESCRIPTION_SEARCHINDEX_DELETE'));
|
||||
|
||||
$search_backend = $input->getArgument('search-backend');
|
||||
|
||||
try
|
||||
@@ -105,8 +107,22 @@ class delete extends command
|
||||
|
||||
try
|
||||
{
|
||||
$search->delete_index($this, '');
|
||||
$search->tidy();
|
||||
// TODO: Read the max_post_id from db because the bucle is not always executed
|
||||
$progress = $this->create_progress_bar(1, $io, $output, true);
|
||||
$progress->setMessage('');
|
||||
$progress->start();
|
||||
|
||||
$counter = 0;
|
||||
while (($status = $search->delete_index($counter)) !== null)
|
||||
{
|
||||
$progress->setMaxSteps($status['max_post_id']);
|
||||
$progress->setProgress($status['post_counter']);
|
||||
$progress->setMessage(round($status['rows_per_second'], 2) . ' rows/s');
|
||||
}
|
||||
|
||||
$progress->finish();
|
||||
|
||||
$io->newLine(2);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
@@ -329,7 +329,8 @@ abstract class base implements search_backend_interface
|
||||
$starttime = microtime(true);
|
||||
$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);
|
||||
|
||||
@@ -356,9 +357,6 @@ abstract class base implements search_backend_interface
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: With cli if the previous bucle have stoped because of lack of time, launch an exception, because is an error
|
||||
// cli commands should be executed in one step
|
||||
|
||||
// pretend the number of posts was as big as the number of ids we indexed so far
|
||||
// just an estimation as it includes deleted posts
|
||||
$num_posts = $this->config['num_posts'];
|
||||
|
Reference in New Issue
Block a user