1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-29 18:50:25 +02:00

Merge PR #949 branch 'dhruvgoel92/ticket/11050' into develop

* dhruvgoel92/ticket/11050:
  [ticket/11050] make all properties protected in all search backends
  [ticket/11050] get_common_words() returns empty array for sphinx
  [ticket/11050] fix tidied search query docblock language
  [ticket/11050] fix min/max length docblock language
  [ticket/11050] multi sentences separated by period in docblocks
  [ticket/11050] fix separated spelling in docblock
  [ticket/11050] fix split words doc block language
  [ticket/11050] remove class word from docblocks
  [ticket/11050] add missing @var in native search
  [ticket/11050] replace user by phpbb_user
  [ticket/11050] fix minor comment/docblocks issues
  [ticket/11050] add access specifiers to native search properties
  [ticket/11050] fix docblocks with description before @var
  [ticket/11050] add missing @var
  [ticket/11050] remove common_words property from sphinx
  [ticket/11050] add access specifiers to sphinx search properties
  [ticket/11050] add access specifiers to mysql search properties
  [ticket/11050] add access specifiers to pgsql search properties
This commit is contained in:
Oleg Pudeyev 2012-11-09 14:01:20 -05:00
commit d99a0fe6b1
4 changed files with 259 additions and 22 deletions

View File

@ -22,18 +22,59 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_search_fulltext_mysql extends phpbb_search_base
{
/**
* Associative array holding index stats
* @var array
*/
protected $stats = array();
/**
* Holds the words entered by user, obtained by splitting the entered query on whitespace
* @var array
*/
protected $split_words = array();
/**
* Config object
* @var phpbb_config
*/
protected $config;
/**
* DBAL object
* @var dbal
*/
protected $db;
/**
* User object
* @var phpbb_user
*/
protected $user;
/**
* Associative array stores the min and max word length to be searched
* @var array
*/
protected $word_length = array();
/**
* Contains tidied search query.
* Operators are prefixed in search query and common words excluded
* @var string
*/
protected $search_query;
/**
* Contains common words.
* Common words are words with length less/more than min/max length
* @var array
*/
protected $common_words = array();
/**
* Constructor
* Creates a new phpbb_search_fulltext_mysql, which is used as a search backend.
* Creates a new phpbb_search_fulltext_mysql, which is used as a search backend
*
* @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false
*/
@ -285,7 +326,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
}
/**
* Performs a search on keywords depending on display specific params. You have to run split_keywords() first.
* Performs a search on keywords depending on display specific params. You have to run split_keywords() first
*
* @param string $type contains either posts or topics depending on what should be searched for
* @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched)
@ -306,7 +347,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
*/
public function keyword_search($type, $fields, $terms, $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 keywords? No posts.
// No keywords? No posts
if (!$this->search_query)
{
return false;
@ -486,7 +527,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
*/
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.
// No author? No posts
if (!sizeof($author_ary))
{
return 0;
@ -635,7 +676,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
}
/**
* Destroys cached search results, that contained one of the new words in a post so the results won't be outdated.
* Destroys cached search results, that contained one of the new words in a post so the results won't be outdated
*
* @param string $mode contains the post mode: edit, post, reply, quote ...
* @param int $post_id contains the post id of the post to index

View File

@ -22,25 +22,84 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_search_fulltext_native extends phpbb_search_base
{
/**
* Associative array holding index stats
* @var array
*/
protected $stats = array();
/**
* Associative array stores the min and max word length to be searched
* @var array
*/
protected $word_length = array();
/**
* Contains tidied search query.
* Operators are prefixed in search query and common words excluded
* @var string
*/
protected $search_query;
/**
* Contains common words.
* Common words are words with length less/more than min/max length
* @var array
*/
protected $common_words = array();
/**
* Post ids of posts containing words that are to be included
* @var array
*/
protected $must_contain_ids = array();
/**
* Post ids of posts containing words that should not be included
* @var array
*/
protected $must_not_contain_ids = array();
/**
* Post ids of posts containing atleast one word that needs to be excluded
* @var array
*/
protected $must_exclude_one_ids = array();
/**
* Relative path to board root
* @var string
*/
protected $phpbb_root_path;
/**
* PHP Extension
* @var string
*/
protected $php_ext;
/**
* Config object
* @var phpbb_config
*/
protected $config;
/**
* DBAL object
* @var dbal
*/
protected $db;
/**
* User object
* @var phpbb_user
*/
protected $user;
/**
* Initialises the fulltext_native search backend with min/max word length and makes sure the UTF-8 normalizer is loaded.
* Initialises the fulltext_native search backend with min/max word length and makes sure the UTF-8 normalizer is loaded
*
* @param boolean|string &$error is passed by reference and should either be set to false on success or an error message on failure.
* @param boolean|string &$error is passed by reference and should either be set to false on success or an error message on failure
*/
public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user)
{
@ -108,14 +167,14 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
/**
* This function fills $this->search_query with the cleaned user search query.
* This function fills $this->search_query with the cleaned user search query
*
* If $terms is 'any' then the words will be extracted from the search query
* and combined with | inside brackets. They will afterwards be treated like
* an standard search query.
*
* Then it analyses the query and fills the internal arrays $must_not_contain_ids,
* $must_contain_ids and $must_exclude_one_ids which are later used by keyword_search().
* $must_contain_ids and $must_exclude_one_ids which are later used by keyword_search()
*
* @param string $keywords contains the search query string as entered by the user
* @param string $terms is either 'all' (use search query as entered, default words to 'must be contained in post')
@ -438,7 +497,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
/**
* Performs a search on keywords depending on display specific params. You have to run split_keywords() first.
* Performs a search on keywords depending on display specific params. You have to run split_keywords() first
*
* @param string $type contains either posts or topics depending on what should be searched for
* @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched)
@ -804,7 +863,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
// if we use mysql and the total result count is not cached yet, retrieve it from the db
if (!$total_results && $is_mysql)
{
// Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it.
// Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it
$sql_array_copy = $sql_array;
$sql_array_copy['SELECT'] = 'SQL_CALC_FOUND_ROWS p.post_id ';
@ -853,7 +912,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
*/
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.
// No author? No posts
if (!sizeof($author_ary))
{
return 0;

View File

@ -22,22 +22,84 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_search_fulltext_postgres extends phpbb_search_base
{
/**
* Associative array holding index stats
* @var array
*/
protected $stats = array();
/**
* Holds the words entered by user, obtained by splitting the entered query on whitespace
* @var array
*/
protected $split_words = array();
/**
* True if PostgreSQL version supports tsearch
* @var boolean
*/
protected $tsearch_usable = false;
/**
* Stores the PostgreSQL version
* @var string
*/
protected $version;
/**
* Stores the tsearch query
* @var string
*/
protected $tsearch_query;
/**
* True if phrase search is supported.
* PostgreSQL fulltext currently doesn't support it
* @var boolean
*/
protected $phrase_search = false;
/**
* Config object
* @var phpbb_config
*/
protected $config;
/**
* DBAL object
* @var dbal
*/
protected $db;
/**
* User object
* @var phpbb_user
*/
protected $user;
/**
* Contains tidied search query.
* Operators are prefixed in search query and common words excluded
* @var string
*/
protected $search_query;
/**
* Contains common words.
* Common words are words with length less/more than min/max length
* @var array
*/
protected $common_words = array();
/**
* Associative array stores the min and max word length to be searched
* @var array
*/
protected $word_length = array();
/**
* Constructor
* Creates a new phpbb_search_fulltext_postgres, which is used as a search backend.
* Creates a new phpbb_search_fulltext_postgres, which is used as a search backend
*
* @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false
*/
@ -254,7 +316,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
}
/**
* Performs a search on keywords depending on display specific params. You have to run split_keywords() first.
* Performs a search on keywords depending on display specific params. You have to run split_keywords() first
*
* @param string $type contains either posts or topics depending on what should be searched for
* @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched)
@ -275,7 +337,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
*/
public function keyword_search($type, $fields, $terms, $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 keywords? No posts.
// No keywords? No posts
if (!$this->search_query)
{
return false;
@ -459,7 +521,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
*/
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.
// No author? No posts
if (!sizeof($author_ary))
{
return 0;
@ -602,7 +664,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
}
/**
* Destroys cached search results, that contained one of the new words in a post so the results won't be outdated.
* Destroys cached search results, that contained one of the new words in a post so the results won't be outdated
*
* @param string $mode contains the post mode: edit, post, reply, quote ...
* @param int $post_id contains the post id of the post to index

View File

@ -28,26 +28,101 @@ define('SPHINX_CONNECT_WAIT_TIME', 300);
*/
class phpbb_search_fulltext_sphinx
{
/**
* Associative array holding index stats
* @var array
*/
protected $stats = array();
/**
* Holds the words entered by user, obtained by splitting the entered query on whitespace
* @var array
*/
protected $split_words = array();
/**
* Holds unique sphinx id
* @var string
*/
protected $id;
/**
* Stores the names of both main and delta sphinx indexes
* separated by a semicolon
* @var string
*/
protected $indexes;
/**
* Sphinx searchd client object
* @var SphinxClient
*/
protected $sphinx;
/**
* Relative path to board root
* @var string
*/
protected $phpbb_root_path;
/**
* PHP Extension
* @var string
*/
protected $php_ext;
/**
* Auth object
* @var phpbb_auth
*/
protected $auth;
/**
* Config object
* @var phpbb_config
*/
protected $config;
/**
* DBAL object
* @var dbal
*/
protected $db;
/**
* Database Tools object
* @var phpbb_db_tools
*/
protected $db_tools;
/**
* Stores the database type if supported by sphinx
* @var string
*/
protected $dbtype;
/**
* User object
* @var phpbb_user
*/
protected $user;
/**
* Stores the generated content of the sphinx config file
* @var string
*/
protected $config_file_data = '';
/**
* Contains tidied search query.
* Operators are prefixed in search query and common words excluded
* @var string
*/
protected $search_query;
protected $common_words = array();
/**
* Constructor
* Creates a new phpbb_search_fulltext_postgres, which is used as a search backend.
* Creates a new phpbb_search_fulltext_postgres, which is used as a search backend
*
* @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false
*/
@ -119,13 +194,13 @@ class phpbb_search_fulltext_sphinx
}
/**
* Returns the common_words array
* Returns an empty array as there are no common_words
*
* @return array common words that are ignored by search backend
*/
public function get_common_words()
{
return $this->common_words;
return array();
}
/**
@ -360,7 +435,7 @@ class phpbb_search_fulltext_sphinx
}
/**
* Performs a search on keywords depending on display specific params. You have to run split_keywords() first.
* Performs a search on keywords depending on display specific params. You have to run split_keywords() first
*
* @param string $type contains either posts or topics depending on what should be searched for
* @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched)