diff options
| author | Dhruv <dhruv.goel92@gmail.com> | 2012-12-21 19:11:20 +0530 | 
|---|---|---|
| committer | Dhruv <dhruv.goel92@gmail.com> | 2013-02-19 00:52:54 +0530 | 
| commit | 2ff874fe930d458382212cfe5495080231ec76e6 (patch) | |
| tree | 3e1161e1ef03bd2c528d2ccb818b8720e418739c | |
| parent | a0ae223ef46e30c9413350ed7c4e52eaab5bb159 (diff) | |
| download | forums-2ff874fe930d458382212cfe5495080231ec76e6.tar forums-2ff874fe930d458382212cfe5495080231ec76e6.tar.gz forums-2ff874fe930d458382212cfe5495080231ec76e6.tar.bz2 forums-2ff874fe930d458382212cfe5495080231ec76e6.tar.xz forums-2ff874fe930d458382212cfe5495080231ec76e6.zip | |
[ticket/11179] correct start parameter in native author search
PHPBB3-11179
| -rw-r--r-- | phpBB/includes/search/fulltext_native.php | 23 | 
1 files changed, 18 insertions, 5 deletions
| diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index fccdcd855e..c9f33054fc 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -920,7 +920,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base  	* @param	int			$per_page			number of ids each page is supposed to contain  	* @return	boolean|int						total number of results  	*/ -	public function author_search($type, $firstpost_only, $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 author_search($type, $firstpost_only, $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 author? No posts  		if (!sizeof($author_ary)) @@ -1106,13 +1106,13 @@ class phpbb_search_fulltext_native extends phpbb_search_base  		if (!$total_results && $is_mysql)  		{  			// Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it. -			$sql = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql); +			$sql_calc = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql); -			$this->db->sql_query($sql); +			$this->db->sql_query($sql_calc);  			$this->db->sql_freeresult($result); -			$sql = 'SELECT FOUND_ROWS() as total_results'; -			$result = $this->db->sql_query($sql); +			$sql_count = 'SELECT FOUND_ROWS() as total_results'; +			$result = $this->db->sql_query($sql_count);  			$total_results = (int) $this->db->sql_fetchfield('total_results');  			$this->db->sql_freeresult($result); @@ -1122,6 +1122,19 @@ class phpbb_search_fulltext_native extends phpbb_search_base  			}  		} +		if ($start >= $total_results) +		{ +			$start = floor(($total_results - 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); +		} +  		if (sizeof($id_ary))  		{  			$this->save_ids($search_key, '', $author_ary, $total_results, $id_ary, $start, $sort_dir); | 
