diff options
| author | Dhruv <dhruv.goel92@gmail.com> | 2012-11-10 13:36:14 +0100 |
|---|---|---|
| committer | Dhruv <dhruv.goel92@gmail.com> | 2013-02-19 00:52:42 +0530 |
| commit | 00d34617ccb6a53185f0e872a735b4dd2f65009b (patch) | |
| tree | a901d53d8d518209dcf114fc3cc87a489ce57ddd /phpBB/includes | |
| parent | 737b99966de8e12ffa13d762b7065043a39399d7 (diff) | |
| download | forums-00d34617ccb6a53185f0e872a735b4dd2f65009b.tar forums-00d34617ccb6a53185f0e872a735b4dd2f65009b.tar.gz forums-00d34617ccb6a53185f0e872a735b4dd2f65009b.tar.bz2 forums-00d34617ccb6a53185f0e872a735b4dd2f65009b.tar.xz forums-00d34617ccb6a53185f0e872a735b4dd2f65009b.zip | |
[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
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/search/base.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/phpBB/includes/search/base.php b/phpBB/includes/search/base.php index b364dead9a..11e5535979 100644 --- a/phpBB/includes/search/base.php +++ b/phpBB/includes/search/base.php @@ -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) |
