diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d3ba635a16..05ea03d446 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -206,7 +206,6 @@ function get_formatted_filesize($value, $string_only = true, $allowed_units = fa */ function still_on_time($extra_time = 15) { - // TODO: Check the bug with this, it should be possible to restart the start time static $max_execution_time, $start_time; $current_time = microtime(true); diff --git a/phpBB/phpbb/console/command/searchindex/create.php b/phpBB/phpbb/console/command/searchindex/create.php index 7352c75be0..e77f833ffb 100644 --- a/phpBB/phpbb/console/command/searchindex/create.php +++ b/phpBB/phpbb/console/command/searchindex/create.php @@ -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); diff --git a/phpBB/phpbb/console/command/searchindex/delete.php b/phpBB/phpbb/console/command/searchindex/delete.php index eff25bb475..45176f785a 100644 --- a/phpBB/phpbb/console/command/searchindex/delete.php +++ b/phpBB/phpbb/console/command/searchindex/delete.php @@ -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) { diff --git a/phpBB/phpbb/search/backend/base.php b/phpBB/phpbb/search/backend/base.php index 4fc2dd9108..3a0049947d 100644 --- a/phpBB/phpbb/search/backend/base.php +++ b/phpBB/phpbb/search/backend/base.php @@ -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'];