From 4d9b106db2ccc6e15b4afd3fc2e69cf37fae81cf Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 11 Apr 2009 11:09:45 +0000 Subject: New search option: Maximum number of words allowed to search for. (the more words the more database load) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9438 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/search/fulltext_native.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/search/fulltext_native.php') diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 1c6a64d07c..ee36039454 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -167,6 +167,13 @@ class fulltext_native extends search_backend ); $keywords = preg_replace($match, $replace, $keywords); + $num_keywords = sizeof(explode(' ', $keywords)); + + // We limit the number of allowed keywords to minimize load on the database + if ($config['max_num_search_keywords'] && $num_keywords > $config['max_num_search_keywords']) + { + trigger_error($user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', $config['max_num_search_keywords'], $num_keywords)); + } // $keywords input format: each word separated by a space, words in a bracket are not separated @@ -693,7 +700,7 @@ class fulltext_native extends search_backend $sql_where[] = 'f.forum_id = p.forum_id'; break; } - + if ($left_join_topics) { $sql_array['LEFT_JOIN'][$left_join_topics] = array( @@ -1110,7 +1117,7 @@ class fulltext_native extends search_backend // Get unique words from the above arrays $unique_add_words = array_unique(array_merge($words['add']['post'], $words['add']['title'])); - + // We now have unique arrays of all words to be added and removed and // individual arrays of added and removed words for text and title. What // we need to do now is add the new words (if they don't already exist) -- cgit v1.2.1