diff options
author | Dhruv <dhruv.goel92@gmail.com> | 2012-12-21 21:54:41 +0530 |
---|---|---|
committer | Dhruv <dhruv.goel92@gmail.com> | 2013-02-19 00:52:55 +0530 |
commit | 38bb7dca31740f9d4f188b75167f736ee6666c2f (patch) | |
tree | 4c230daa8fa1168ae49969e938662a6e45076dea /phpBB/includes/search | |
parent | 2ff874fe930d458382212cfe5495080231ec76e6 (diff) | |
download | forums-38bb7dca31740f9d4f188b75167f736ee6666c2f.tar forums-38bb7dca31740f9d4f188b75167f736ee6666c2f.tar.gz forums-38bb7dca31740f9d4f188b75167f736ee6666c2f.tar.bz2 forums-38bb7dca31740f9d4f188b75167f736ee6666c2f.tar.xz forums-38bb7dca31740f9d4f188b75167f736ee6666c2f.zip |
[ticket/11179] correct start parameter in sphinx search
PHPBB3-11179
Diffstat (limited to 'phpBB/includes/search')
-rw-r--r-- | phpBB/includes/search/fulltext_sphinx.php | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php index 7304e70ff8..48445d0794 100644 --- a/phpBB/includes/search/fulltext_sphinx.php +++ b/phpBB/includes/search/fulltext_sphinx.php @@ -454,7 +454,7 @@ class phpbb_search_fulltext_sphinx * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) + public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No keywords? No posts. if (!strlen($this->search_query) && !sizeof($author_ary)) @@ -609,6 +609,25 @@ class phpbb_search_fulltext_sphinx } } + $result_count = $result['total_found']; + + if ($start >= $result_count) + { + $start = floor(($result_count - 1) / $per_page) * $per_page; + + $this->sphinx->SetLimits((int) $start, (int) $per_page, SPHINX_MAX_MATCHES); + $result = $this->sphinx->Query($search_query_prefix . str_replace('"', '"', $this->search_query), $this->indexes); + + // Could be connection to localhost:9312 failed (errno=111, + // msg=Connection refused) during rotate, retry if so + $retries = SPHINX_CONNECT_RETRIES; + while (!$result && (strpos($this->sphinx->GetLastError(), "errno=111,") !== false) && $retries--) + { + usleep(SPHINX_CONNECT_WAIT_TIME); + $result = $this->sphinx->Query($search_query_prefix . str_replace('"', '"', $this->search_query), $this->indexes); + } + } + $id_ary = array(); if (isset($result['matches'])) { @@ -629,8 +648,6 @@ class phpbb_search_fulltext_sphinx return false; } - $result_count = $result['total_found']; - $id_ary = array_slice($id_ary, 0, (int) $per_page); return $result_count; |