aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/search/fulltext_postgres.php
diff options
context:
space:
mode:
authorDhruv <dhruv.goel92@gmail.com>2012-11-10 15:35:05 +0100
committerDhruv <dhruv.goel92@gmail.com>2013-02-19 00:52:47 +0530
commit2cb48f034153038d71d89ab58904cd048b8524d9 (patch)
treee4f520b7c08eac49c781c14ceac13a0d941162e5 /phpBB/includes/search/fulltext_postgres.php
parent80f8e3abceabab658a5a935e5a6079e73f663698 (diff)
downloadforums-2cb48f034153038d71d89ab58904cd048b8524d9.tar
forums-2cb48f034153038d71d89ab58904cd048b8524d9.tar.gz
forums-2cb48f034153038d71d89ab58904cd048b8524d9.tar.bz2
forums-2cb48f034153038d71d89ab58904cd048b8524d9.tar.xz
forums-2cb48f034153038d71d89ab58904cd048b8524d9.zip
[ticket/11179] correct start parameter in psql keyword search
PHPBB3-11179
Diffstat (limited to 'phpBB/includes/search/fulltext_postgres.php')
-rw-r--r--phpBB/includes/search/fulltext_postgres.php25
1 files changed, 20 insertions, 5 deletions
diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php
index 1475cc31d0..d968a934f4 100644
--- a/phpBB/includes/search/fulltext_postgres.php
+++ b/phpBB/includes/search/fulltext_postgres.php
@@ -371,6 +371,11 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
implode(',', $author_ary)
)));
+ if ($start < 0)
+ {
+ $start = 0;
+ }
+
// try reading the results from cache
$result_count = 0;
if ($this->obtain_ids($search_key, $result_count, $id_ary, $start, $per_page, $sort_dir) == SEARCH_RESULT_IN_CACHE)
@@ -495,11 +500,6 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$id_ary = array_unique($id_ary);
- if (!sizeof($id_ary))
- {
- return false;
- }
-
// if the total result count is not cached yet, retrieve it from the db
if (!$result_count)
{
@@ -518,6 +518,21 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$this->db->sql_transaction('commit');
+ if ($start >= $result_count)
+ {
+ $start = floor(($result_count - 1) / $per_page) * $per_page;
+ }
+
+ $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
+
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $id_ary[] = $row[$field];
+ }
+ $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, implode(' ', $this->split_words), $author_ary, $result_count, $id_ary, $start, $sort_dir);
$id_ary = array_slice($id_ary, 0, (int) $per_page);