diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acp/acp_search.php | 2 | ||||
-rw-r--r-- | phpBB/includes/search/fulltext_mysql.php | 8 | ||||
-rw-r--r-- | phpBB/includes/search/fulltext_native.php | 11 |
3 files changed, 18 insertions, 3 deletions
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index dc6f3d1c44..66edbd44ae 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -63,6 +63,7 @@ class acp_search 'load_search' => 'bool', 'limit_search_load' => 'float', 'min_search_author_chars' => 'integer', + 'max_num_search_keywords' => 'integer', 'search_store_results' => 'integer', ); @@ -216,6 +217,7 @@ class acp_search 'SEARCH_INTERVAL' => (float) $config['search_interval'], 'SEARCH_GUEST_INTERVAL' => (float) $config['search_anonymous_interval'], 'SEARCH_STORE_RESULTS' => (int) $config['search_store_results'], + 'MAX_NUM_SEARCH_KEYWORDS' => (int) $config['max_num_search_keywords'], 'S_SEARCH_TYPES' => $search_options, 'S_YES_SEARCH' => (bool) $config['load_search'], diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 2a67b58246..e1e7951367 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -118,7 +118,7 @@ class fulltext_mysql extends search_backend */ function split_keywords(&$keywords, $terms) { - global $config; + global $config, $user; if ($terms == 'all') { @@ -167,6 +167,12 @@ class fulltext_mysql extends search_backend $this->split_words = $matches[1]; } + // We limit the number of allowed keywords to minimize load on the database + if ($config['max_num_search_keywords'] && sizeof($this->split_words) > $config['max_num_search_keywords']) + { + trigger_error($user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', $config['max_num_search_keywords'], sizeof($this->split_words))); + } + // to allow phrase search, we need to concatenate quoted words $tmp_split_words = array(); $phrase = ''; 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) |