diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index 3b6febd566..c4bf11e4cf 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -322,9 +322,9 @@ class acp_search { $sql = 'SELECT post_id, poster_id, forum_id FROM ' . POSTS_TABLE . ' - WHERE post_id >= ' . (int) ($post_counter + 1) . ' - AND post_id <= ' . (int) ($post_counter + $this->batch_size); - $result = $db->sql_query($sql); + WHERE post_id > ' . (int) $post_counter . ' + ORDER BY post_id ASC'; + $result = $db->sql_query_limit($sql, $this->batch_size); $ids = $posters = $forum_ids = array(); while ($row = $db->sql_fetchrow($result)) @@ -339,14 +339,13 @@ class acp_search if (count($ids)) { $this->search->index_remove($ids, $posters, $forum_ids); + $post_counter = $ids[count($ids) - 1]; } - - $post_counter += $this->batch_size; } // save the current state $this->save_state(); - if ($post_counter <= $this->max_post_id) + if ($post_counter < $this->max_post_id) { $totaltime = microtime(true) - $starttime; $rows_per_second = $row_count / $totaltime; @@ -393,9 +392,9 @@ class acp_search { $sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id FROM ' . POSTS_TABLE . ' - WHERE post_id >= ' . (int) ($post_counter + 1) . ' - AND post_id <= ' . (int) ($post_counter + $this->batch_size); - $result = $db->sql_query($sql); + WHERE post_id > ' . (int) $post_counter . ' + ORDER BY post_id ASC'; + $result = $db->sql_query_limit($sql, $this->batch_size); $buffer = $db->sql_buffer_nested_transactions(); @@ -416,13 +415,12 @@ class acp_search $this->search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']); } $row_count++; + $post_counter = $row['post_id']; } if (!$buffer) { $db->sql_freeresult($result); } - - $post_counter += $this->batch_size; } // save the current state $this->save_state(); @@ -434,7 +432,7 @@ class acp_search $this->search->tidy(); $config['num_posts'] = $num_posts; - if ($post_counter <= $this->max_post_id) + if ($post_counter < $this->max_post_id) { $totaltime = microtime(true) - $starttime; $rows_per_second = $row_count / $totaltime;