[ticket/16913] Move code in index action and remove not needed global

PHPBB3-16913
This commit is contained in:
Marc Alexander 2022-12-30 11:39:03 +01:00
parent 94ed73b812
commit df476f733f
No known key found for this signature in database
GPG key ID: 50E0D2423696F995

View file

@ -371,6 +371,13 @@ class acp_search
*/
private function index_action(string $id, string $mode, string $action): void
{
// Start displaying progress on first submit
if ($this->request->is_set_post('submit'))
{
$this->display_progress_bar($id, $mode);
return;
}
// For some this may be of help...
@ini_set('memory_limit', '128M');
@ -392,13 +399,6 @@ class acp_search
}
}
// Start displaying progress on first submit
if ($this->request->is_set_post('submit'))
{
$this->display_progress_bar($id, $mode);
return;
}
// Execute create/delete
$type = $this->search_state_helper->type();
$action = $this->search_state_helper->action();
@ -499,21 +499,19 @@ class acp_search
*/
protected function get_post_index_progress(int $post_counter): array
{
global $db;
$sql = 'SELECT COUNT(post_id) as done_count
FROM ' . POSTS_TABLE . '
WHERE post_id <= ' . $post_counter;
$result = $db->sql_query($sql);
$done_count = (int) $db->sql_fetchfield('done_count');
$db->sql_freeresult($result);
$result = $this->db->sql_query($sql);
$done_count = (int) $this->db->sql_fetchfield('done_count');
$this->db->sql_freeresult($result);
$sql = 'SELECT COUNT(post_id) as remain_count
FROM ' . POSTS_TABLE . '
WHERE post_id > ' . $post_counter;
$result = $db->sql_query($sql);
$remain_count = (int) $db->sql_fetchfield('remain_count');
$db->sql_freeresult($result);
$result = $this->db->sql_query($sql);
$remain_count = (int) $this->db->sql_fetchfield('remain_count');
$this->db->sql_freeresult($result);
$total_count = $done_count + $remain_count;
$percent = ($done_count / $total_count) * 100;