diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index cf89ab1c24..7cd06dee19 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -27,9 +27,9 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
protected $config;
protected $db;
protected $user;
- public $word_length = array();
- public $search_query;
- public $common_words = array();
+ protected $word_length = array();
+ protected $search_query;
+ protected $common_words = array();
/**
* Constructor
@@ -58,6 +58,36 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
return 'MySQL Fulltext';
}
+ /**
+ * Returns the search_query
+ *
+ * @return string search query
+ */
+ public function get_search_query()
+ {
+ return $this->search_query;
+ }
+
+ /**
+ * Returns the common_words array
+ *
+ * @return array common words that are ignored by search backend
+ */
+ public function get_common_words()
+ {
+ return $this->common_words;
+ }
+
+ /**
+ * Returns the word_length array
+ *
+ * @return array min and max word length for searching
+ */
+ public function get_word_length()
+ {
+ return $this->word_length;
+ }
+
/**
* Checks for correct MySQL version and stores min/max word length in the config
*
diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php
index 96b3f02ec6..bbc2236b3c 100644
--- a/phpBB/includes/search/fulltext_native.php
+++ b/phpBB/includes/search/fulltext_native.php
@@ -23,9 +23,9 @@ if (!defined('IN_PHPBB'))
class phpbb_search_fulltext_native extends phpbb_search_base
{
protected $stats = array();
- public $word_length = array();
- public $search_query;
- public $common_words = array();
+ protected $word_length = array();
+ protected $search_query;
+ protected $common_words = array();
protected $must_contain_ids = array();
protected $must_not_contain_ids = array();
@@ -73,6 +73,36 @@ class phpbb_search_fulltext_native extends phpbb_search_base
return 'phpBB Native Fulltext';
}
+ /**
+ * Returns the search_query
+ *
+ * @return string search query
+ */
+ public function get_search_query()
+ {
+ return $this->search_query;
+ }
+
+ /**
+ * Returns the common_words array
+ *
+ * @return array common words that are ignored by search backend
+ */
+ public function get_common_words()
+ {
+ return $this->common_words;
+ }
+
+ /**
+ * Returns the word_length array
+ *
+ * @return array min and max word length for searching
+ */
+ public function get_word_length()
+ {
+ return $this->word_length;
+ }
+
/**
* This function fills $this->search_query with the cleaned user search query.
*
diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php
index 50ed785093..38989a9d9a 100644
--- a/phpBB/includes/search/fulltext_postgres.php
+++ b/phpBB/includes/search/fulltext_postgres.php
@@ -31,9 +31,9 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
protected $config;
protected $db;
protected $user;
- public $search_query;
- public $common_words = array();
- public $word_length = array();
+ protected $search_query;
+ protected $common_words = array();
+ protected $word_length = array();
/**
* Constructor
@@ -72,6 +72,36 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
return 'PostgreSQL Fulltext';
}
+ /**
+ * Returns the search_query
+ *
+ * @return string search query
+ */
+ public function get_search_query()
+ {
+ return $this->search_query;
+ }
+
+ /**
+ * Returns the common_words array
+ *
+ * @return array common words that are ignored by search backend
+ */
+ public function get_common_words()
+ {
+ return $this->common_words;
+ }
+
+ /**
+ * Returns the word_length array
+ *
+ * @return array min and max word length for searching
+ */
+ public function get_word_length()
+ {
+ return $this->word_length;
+ }
+
/**
* Returns if phrase search is supported or not
*
diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php
index 288c0b5940..0a230f0e98 100644
--- a/phpBB/includes/search/fulltext_sphinx.php
+++ b/phpBB/includes/search/fulltext_sphinx.php
@@ -42,8 +42,8 @@ class phpbb_search_fulltext_sphinx
protected $dbtype;
protected $user;
protected $config_file_data = '';
- public $search_query;
- public $common_words = array();
+ protected $search_query;
+ protected $common_words = array();
/**
* Constructor
@@ -87,7 +87,7 @@ class phpbb_search_fulltext_sphinx
$error = false;
}
-
+
/**
* Returns the name of this search backend to be displayed to administrators
*
@@ -98,6 +98,36 @@ class phpbb_search_fulltext_sphinx
return 'Sphinx Fulltext';
}
+ /**
+ * Returns the search_query
+ *
+ * @return string search query
+ */
+ public function get_search_query()
+ {
+ return $this->search_query;
+ }
+
+ /**
+ * Returns false as there is no word_len array
+ *
+ * @return false
+ */
+ public function get_word_length()
+ {
+ return false;
+ }
+
+ /**
+ * Returns the common_words array
+ *
+ * @return array common words that are ignored by search backend
+ */
+ public function get_common_words()
+ {
+ return $this->common_words;
+ }
+
/**
* Checks permissions and paths, if everything is correct it generates the config file
*
diff --git a/phpBB/search.php b/phpBB/search.php
index 190da5247f..7eda3c4d1d 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -287,14 +287,24 @@ if ($keywords || $author || $author_id || $search_id || $submit)
trigger_error($error);
}
+ $common_words = $search->get_common_words();
+
// let the search module split up the keywords
if ($keywords)
{
$correct_query = $search->split_keywords($keywords, $search_terms);
- if (!$correct_query || (empty($search->search_query) && !sizeof($author_id_ary) && !$search_id))
+ if (!$correct_query || (!$search->get_search_query() && !sizeof($author_id_ary) && !$search_id))
{
- $ignored = (sizeof($search->common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $search->common_words)) . '
' : '';
- trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $search->word_length['min']), $user->lang('CHARACTERS', (int) $search->word_length['max'])));
+ $ignored = (sizeof($common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $common_words)) . '
' : '';
+ $word_length = $search->get_word_length();
+ if ($word_length)
+ {
+ trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $word_length['min']), $user->lang('CHARACTERS', (int) $word_length['max'])));
+ }
+ else
+ {
+ trigger_error($ignored);
+ }
}
}
@@ -526,7 +536,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
sort($m_approve_fid_ary);
sort($author_id_ary);
- if (!empty($search->search_query))
+ if ($search->get_search_query())
{
$total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);
}
@@ -609,8 +619,8 @@ if ($keywords || $author || $author_id || $search_id || $submit)
'SEARCH_TITLE' => $l_search_title,
'SEARCH_MATCHES' => $l_search_matches,
'SEARCH_WORDS' => $keywords,
- 'SEARCHED_QUERY' => $search->search_query,
- 'IGNORED_WORDS' => (sizeof($search->common_words)) ? implode(' ', $search->common_words) : '',
+ 'SEARCHED_QUERY' => $search->get_search_query(),
+ 'IGNORED_WORDS' => (sizeof($common_words)) ? implode(' ', $common_words) : '',
'PAGE_NUMBER' => phpbb_on_page($template, $user, $u_search, $total_match_count, $per_page, $start),
'PHRASE_SEARCH_DISABLED' => $phrase_search_disabled,