Compare commits

..

1 commit

Author SHA1 Message Date
rxu
97ac9cc783
[ticket/17491] Add test
PHPBB-17491
2025-05-05 16:57:54 +07:00
4 changed files with 21 additions and 22 deletions

View file

@ -609,6 +609,7 @@ class fulltext_mysql extends \phpbb\search\base
}
$this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
// if the total result count is not cached yet, retrieve it from the db
if (!$result_count && count($id_ary))
{
@ -634,9 +635,9 @@ class fulltext_mysql extends \phpbb\search\base
$id_ary[] = (int) $row[$field];
}
$this->db->sql_freeresult($result);
}
$id_ary = array_unique($id_ary);
$id_ary = array_unique($id_ary);
}
// store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page
$this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir);
@ -895,9 +896,9 @@ class fulltext_mysql extends \phpbb\search\base
$id_ary[] = (int) $row[$field];
}
$this->db->sql_freeresult($result);
}
$id_ary = array_unique($id_ary);
$id_ary = array_unique($id_ary);
}
if (count($id_ary))
{

View file

@ -1012,8 +1012,6 @@ class fulltext_native extends \phpbb\search\base
$this->db->sql_freeresult($result);
}
$id_ary = array_unique($id_ary);
// store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page
$this->save_ids($search_key, $this->search_query, $author_ary, $total_results, $id_ary, $start, $sort_dir);
$id_ary = array_slice($id_ary, 0, (int) $per_page);
@ -1315,8 +1313,6 @@ class fulltext_native extends \phpbb\search\base
$this->db->sql_freeresult($result);
}
$id_ary = array_unique($id_ary);
if (count($id_ary))
{
$this->save_ids($search_key, '', $author_ary, $total_results, $id_ary, $start, $sort_dir);

View file

@ -545,6 +545,8 @@ class fulltext_postgres extends \phpbb\search\base
}
$this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
// if the total result count is not cached yet, retrieve it from the db
if (!$result_count)
{
@ -574,9 +576,9 @@ class fulltext_postgres extends \phpbb\search\base
$id_ary[] = $row[$field];
}
$this->db->sql_freeresult($result);
}
$id_ary = array_unique($id_ary);
$id_ary = array_unique($id_ary);
}
// store the ids, from start on then delete anything that isn't on the current page because we only need ids for one page
$this->save_ids($search_key, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir);
@ -856,9 +858,9 @@ class fulltext_postgres extends \phpbb\search\base
$id_ary[] = (int) $row[$field];
}
$this->db->sql_freeresult($result);
}
$id_ary = array_unique($id_ary);
$id_ary = array_unique($id_ary);
}
if (count($id_ary))
{

View file

@ -326,31 +326,31 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
// Get cached post ids data
$cache = $this->get_cache_driver();
$post_ids_cached = $cache->get($cache_varname);
$cached_results_count = count($post_ids_cached) - 2; // Don't count '-1' and '-2' indexes
$post_ids_cached_backup = $post_ids_cached;
// Cached data still should have initial 'd' sort direction
$this->assertTrue($post_ids_cached[-2] === 'd', $this->search_backend);
// Cached search results count should be equal to displayed on search results page
$this->assertEquals($posts_count, $post_ids_cached[-1], $this->search_backend);
// Cached search results count should be more than or equal to displayed one
$this->assertGreaterThanOrEqual($posts_count, $post_ids_cached[-1], $this->search_backend);
// Actual cached data array count should be equal to displayed on search results page too
$this->assertEquals($posts_count, $cached_results_count, $this->search_backend);
// Cached data array shouldn't change after removing duplicates. That is, it shouldn't have any duplicates.
/* Check post ids cached data. Array shouldn't change after removing duplicates and re-sorting.
* That means it shouldn't have any duplicates and it should be properly ordered already
*/
unset($post_ids_cached[-2], $post_ids_cached[-1]);
unset($post_ids_cached_backup[-2], $post_ids_cached_backup[-1]);
$post_ids_cached = array_unique($post_ids_cached);
rsort($post_ids_cached);
$this->assertEquals($post_ids_cached_backup, $post_ids_cached, $this->search_backend);
// Restore this value to default
$sql = 'UPDATE ' . CONFIG_TABLE . "
SET config_value = 250
$sql = 'UPDATE ' . CONFIG_TABLE . '
SET config_value = ' . floor($posts_count / 3) . "
WHERE config_name = '" . $this->db->sql_escape('search_block_size') . "'";
$this->db->sql_query($sql);
$crawler = self::submit($form);
$this->assertEquals(1, $crawler->filter('.successbox')->count(), $this->search_backend);
// Restore posts_per_page value
$crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post');