aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/search/fulltext_mysql.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2013-03-03 20:06:52 +0100
committerJoas Schilling <nickvergessen@gmx.de>2013-03-03 20:06:52 +0100
commit42c062cedf0b451141e321dd4e7cac84905bcac6 (patch)
tree7c6fa2647ebbd56e909356de4a27551dff0be626 /phpBB/includes/search/fulltext_mysql.php
parent3cee183dd4882fdd00deb911bab69287d7754135 (diff)
parentbee4f8d8185d4ff5278be758db4ea4a814f09b4f (diff)
downloadforums-42c062cedf0b451141e321dd4e7cac84905bcac6.tar
forums-42c062cedf0b451141e321dd4e7cac84905bcac6.tar.gz
forums-42c062cedf0b451141e321dd4e7cac84905bcac6.tar.bz2
forums-42c062cedf0b451141e321dd4e7cac84905bcac6.tar.xz
forums-42c062cedf0b451141e321dd4e7cac84905bcac6.zip
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into feature/softdelete-1-permission
* 'develop' of https://github.com/phpbb/phpbb3: (480 commits) [ticket/6723] Show info that message has been deleted before delivery [ticket/11385] Fix issue with migration module tool not getting extension module info [ticket/11386] Fix failing tests from constructor changes [ticket/11386] Fix circular reference error & serialize error [ticket/11386] Remove tests that check if finder cache is working [ticket/11386] Forgot to get the migration classes [ticket/11386] Update tests with new constructors for ext.manager/migrator [ticket/11386] Use finder to find migration files [ticket/11363] Fix to make get_module_infos get from all extensions [ticket/11381] Make finder able to search in all available extensions [ticket/11103] Revert whitespace changes [ticket/11103] Few more minor language things [ticket/11103] Don't call generate_board_url many times [ticket/11103] Case time in queries as an int [ticket/11103] Fix effectively installed check [ticket/11103] Remove padding from notifications for now. [ticket/11363] Fix a couple bugs and throw errors if the file not found [ticket/11372] Migrator should only check if effectively installed if not [ticket/11363] Load module info files for extensions too [ticket/11103] Notifications Migration file ... Conflicts: phpBB/includes/functions_posting.php phpBB/includes/mcp/mcp_queue.php phpBB/includes/search/fulltext_mysql.php phpBB/includes/search/fulltext_native.php phpBB/includes/search/fulltext_postgres.php phpBB/includes/search/fulltext_sphinx.php phpBB/install/database_update.php phpBB/styles/prosilver/template/ajax.js
Diffstat (limited to 'phpBB/includes/search/fulltext_mysql.php')
-rw-r--r--phpBB/includes/search/fulltext_mysql.php56
1 files changed, 45 insertions, 11 deletions
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index 913334bd08..e3ec56423e 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -353,7 +353,7 @@ class phpbb_search_fulltext_mysql 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 keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $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, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)
{
// No keywords? No posts
if (!$this->search_query)
@@ -375,6 +375,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
implode(',', $author_ary)
)));
+ 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)
@@ -475,16 +480,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$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
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);
@@ -494,6 +494,21 @@ 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);
+ }
+
// 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);
$id_ary = array_slice($id_ary, 0, (int) $per_page);
@@ -520,7 +535,7 @@ class phpbb_search_fulltext_mysql 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))
@@ -544,6 +559,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)
@@ -638,8 +658,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);
@@ -649,6 +669,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);