aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/search
diff options
context:
space:
mode:
authorDhruv <dhruv.goel92@gmail.com>2012-11-10 14:28:29 +0100
committerDhruv <dhruv.goel92@gmail.com>2013-02-19 00:52:45 +0530
commit2601411a9cfb79de1c45523005e91f00a8583ad1 (patch)
tree6a650a2d81249a278aaf71260c01ce52ff7825e3 /phpBB/includes/search
parent1c9c666ef193942a2d88ec59741ddc49900e92e9 (diff)
downloadforums-2601411a9cfb79de1c45523005e91f00a8583ad1.tar
forums-2601411a9cfb79de1c45523005e91f00a8583ad1.tar.gz
forums-2601411a9cfb79de1c45523005e91f00a8583ad1.tar.bz2
forums-2601411a9cfb79de1c45523005e91f00a8583ad1.tar.xz
forums-2601411a9cfb79de1c45523005e91f00a8583ad1.zip
[ticket/11179] correct start parameter for author search
PHPBB3-11179
Diffstat (limited to 'phpBB/includes/search')
-rw-r--r--phpBB/includes/search/fulltext_mysql.php23
1 files changed, 21 insertions, 2 deletions
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index 3ecc2cd39d..54e2007da3 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -571,6 +571,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$author_name,
)));
+ 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)
@@ -676,8 +681,8 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
// retrieve the total result count if needed
if (!$result_count)
{
- $sql = 'SELECT FOUND_ROWS() as result_count';
- $result = $this->db->sql_query($sql);
+ $sql_found_rows = 'SELECT FOUND_ROWS() as result_count';
+ $result = $this->db->sql_query($sql_found_rows);
$result_count = (int) $this->db->sql_fetchfield('result_count');
$this->db->sql_freeresult($result);
@@ -687,6 +692,20 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
}
}
+ 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[] = (int) $row[$field];
+ }
+ $this->db->sql_freeresult($result);
+
+ $id_ary = array_unique($id_ary);
+
if (sizeof($id_ary))
{
$this->save_ids($search_key, '', $author_ary, $result_count, $id_ary, $start, $sort_dir);