From f0d63594e68fa7a165b8ba90d0fcf35f38e42de9 Mon Sep 17 00:00:00 2001
From: Dhruv <dhruv.goel92@gmail.com>
Date: Sun, 2 Dec 2012 14:15:04 +0530
Subject: [ticket/11179] fix success query path for mysql

Additional query to check start parameter executed only incase of no
results.

PHPBB3-11179
---
 phpBB/includes/search/fulltext_mysql.php | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

(limited to 'phpBB/includes/search/fulltext_mysql.php')

diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index ad5119f67c..4dc62753aa 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -510,17 +510,17 @@ 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);
+			$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);
+			while ($row = $this->db->sql_fetchrow($result))
+			{
+				$id_ary[] = (int) $row[$field];
+			}
+			$this->db->sql_freeresult($result);
 
-		$id_ary = array_unique($id_ary);
+			$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);
@@ -696,16 +696,16 @@ 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);
+			$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);
+			$id_ary = array_unique($id_ary);
+		}
 
 		if (sizeof($id_ary))
 		{
-- 
cgit v1.2.1