[ticket/11179] correct the start parameter while retrieving from cache

Start parameter if not between 0 and the total result count of the cached
search results is changed accordingly

PHPBB3-11179
This commit is contained in:
Dhruv 2012-11-10 13:36:14 +01:00
parent 737b99966d
commit 00d34617cc

View file

@ -97,7 +97,6 @@ class phpbb_search_base
function obtain_ids($search_key, &$result_count, &$id_ary, $start, $per_page, $sort_dir)
{
global $cache;
if (!($stored_ids = $cache->get('_search_results_' . $search_key)))
{
// no search results cached for this search_key
@ -109,6 +108,19 @@ class phpbb_search_base
$reverse_ids = ($stored_ids[-2] != $sort_dir) ? true : false;
$complete = true;
// change start parameter in case out of bounds
if ($result_count)
{
if ($start < 0)
{
$start = 0;
}
else if ($start >= $result_count)
{
$start = floor(($result_count - 1) / $per_page) * $per_page;
}
}
// change the start to the actual end of the current request if the sort direction differs
// from the dirction in the cache and reverse the ids later
if ($reverse_ids)