aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhruv <dhruv.goel92@gmail.com>2012-11-10 03:39:51 +0530
committerDhruv <dhruv.goel92@gmail.com>2013-02-19 00:52:41 +0530
commit737b99966de8e12ffa13d762b7065043a39399d7 (patch)
treebaac60a7ab1db723aaf392586177829ee91c5a00
parent0f89b488202f988e4f18264f4e05879f760d0ce9 (diff)
downloadforums-737b99966de8e12ffa13d762b7065043a39399d7.tar
forums-737b99966de8e12ffa13d762b7065043a39399d7.tar.gz
forums-737b99966de8e12ffa13d762b7065043a39399d7.tar.bz2
forums-737b99966de8e12ffa13d762b7065043a39399d7.tar.xz
forums-737b99966de8e12ffa13d762b7065043a39399d7.zip
[ticket/11179] add search query in case initial one fails
changes the start parameter according to the total search results and executes the search query again to get the results. PHPBB3-11179
-rw-r--r--phpBB/includes/search/fulltext_mysql.php34
1 files changed, 32 insertions, 2 deletions
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index 324c214e91..acb1a7bde8 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -381,7 +381,6 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
{
return $result_count;
}
-
$id_ary = array();
$join_topic = ($type == 'posts') ? false : true;
@@ -490,7 +489,38 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
if (!sizeof($id_ary))
{
- return false;
+ $sql_count = "SELECT COUNT(*) as result_count
+ FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p
+ WHERE MATCH ($sql_match) AGAINST ('" . $this->db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE)
+ $sql_where_options
+ ORDER BY $sql_sort";
+ $result = $this->db->sql_query($sql_count);
+ $total_match_count = (int) $this->db->sql_fetchfield('result_count');
+
+ if ($total_match_count)
+ {
+ if ($start < 0)
+ {
+ $start = 0;
+ }
+ else if ($start >= $total_match_count)
+ {
+ $start = floor(($total_match_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))
+ {
+ return false;
+ }
}
// if the total result count is not cached yet, retrieve it from the db