mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/postgresql-fulltext-search] remove mbstring support
Remove the usage of mbstring regex engine when PCRE does not support UTF8 since its a requirement for phpbb 3.1 PHPBB3-9730
This commit is contained in:
parent
8981399ae1
commit
84054afc9d
2 changed files with 8 additions and 83 deletions
|
@ -29,7 +29,6 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
|||
var $tsearch_query;
|
||||
var $common_words = array();
|
||||
var $pcre_properties = false;
|
||||
var $mbstring_regex = false;
|
||||
var $tsearch_usable = false;
|
||||
|
||||
public function __construct(&$error)
|
||||
|
@ -44,11 +43,6 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
|||
$this->pcre_properties = true;
|
||||
}
|
||||
|
||||
if (function_exists('mb_ereg'))
|
||||
{
|
||||
$this->mbstring_regex = true;
|
||||
}
|
||||
|
||||
if ($db->sql_layer == 'postgres')
|
||||
{
|
||||
$pgsql_version = explode('.', substr($db->sql_server_info(), 10));
|
||||
|
@ -115,41 +109,10 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
|||
$split_keywords = preg_replace("#[\"\n\r\t]+#", ' ', trim(htmlspecialchars_decode($keywords)));
|
||||
|
||||
// Split words
|
||||
if ($this->pcre_properties)
|
||||
{
|
||||
$split_keywords = preg_replace('#([^\p{L}\p{N}\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords)));
|
||||
}
|
||||
else if ($this->mbstring_regex)
|
||||
{
|
||||
$split_keywords = mb_ereg_replace('([^\w\'*"()])', '\\1\\1', str_replace('\'\'', '\' \'', trim($split_keywords)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$split_keywords = preg_replace('#([^\w\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords)));
|
||||
}
|
||||
|
||||
if ($this->pcre_properties)
|
||||
{
|
||||
$matches = array();
|
||||
preg_match_all('#(?:[^\p{L}\p{N}*"()]|^)([+\-|]?(?:[\p{L}\p{N}*"()]+\'?)*[\p{L}\p{N}*"()])(?:[^\p{L}\p{N}*"()]|$)#u', $split_keywords, $matches);
|
||||
$this->split_words = $matches[1];
|
||||
}
|
||||
else if ($this->mbstring_regex)
|
||||
{
|
||||
mb_regex_encoding('UTF-8');
|
||||
mb_ereg_search_init($split_keywords, '(?:[^\w*"()]|^)([+\-|]?(?:[\w*"()]+\'?)*[\w*"()])(?:[^\w*"()]|$)');
|
||||
|
||||
while (($word = mb_ereg_search_regs()))
|
||||
{
|
||||
$this->split_words[] = $word[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$matches = array();
|
||||
preg_match_all('#(?:[^\w*"()]|^)([+\-|]?(?:[\w*"()]+\'?)*[\w*"()])(?:[^\w*"()]|$)#u', $split_keywords, $matches);
|
||||
$this->split_words = $matches[1];
|
||||
}
|
||||
|
||||
// to allow phrase search, we need to concatenate quoted words
|
||||
$tmp_split_words = array();
|
||||
|
@ -260,42 +223,10 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
|||
global $config;
|
||||
|
||||
// Split words
|
||||
if ($this->pcre_properties)
|
||||
{
|
||||
$text = preg_replace('#([^\p{L}\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
|
||||
}
|
||||
else if ($this->mbstring_regex)
|
||||
{
|
||||
$text = mb_ereg_replace('([^\w\'*])', '\\1\\1', str_replace('\'\'', '\' \'', trim($text)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = preg_replace('#([^\w\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
|
||||
}
|
||||
|
||||
if ($this->pcre_properties)
|
||||
{
|
||||
$matches = array();
|
||||
preg_match_all('#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u', $text, $matches);
|
||||
$text = $matches[1];
|
||||
}
|
||||
else if ($this->mbstring_regex)
|
||||
{
|
||||
mb_regex_encoding('UTF-8');
|
||||
mb_ereg_search_init($text, '(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)');
|
||||
|
||||
$text = array();
|
||||
while (($word = mb_ereg_search_regs()))
|
||||
{
|
||||
$text[] = $word[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$matches = array();
|
||||
preg_match_all('#(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)#u', $text, $matches);
|
||||
$text = $matches[1];
|
||||
}
|
||||
|
||||
// remove too short or too long words
|
||||
$text = array_values($text);
|
||||
|
@ -858,10 +789,6 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
|
|||
<dt><label>' . $user->lang['FULLTEXT_POSTGRES_PCRE'] . '</label><br /><span>' . $user->lang['FULLTEXT_POSTGRES_PCRE_EXPLAIN'] . '</span></dt>
|
||||
<dd>' . (($this->pcre_properties) ? $user->lang['YES'] : $user->lang['NO']) . ' (PHP ' . PHP_VERSION . ')</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label>' . $user->lang['FULLTEXT_POSTGRES_MBSTRING'] . '</label><br /><span>' . $user->lang['FULLTEXT_POSTGRES_MBSTRING_EXPLAIN'] . '</span></dt>
|
||||
<dd>' . (($this->mbstring_regex) ? $user->lang['YES'] : $user->lang['NO']). '</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label>' . $user->lang['FULLTEXT_POSTGRES_TS_NAME'] . '</label><br /><span>' . $user->lang['FULLTEXT_POSTGRES_TS_NAME_EXPLAIN'] . '</span></dt>
|
||||
<dd><select name="config[fulltext_postgres_ts_name]">';
|
||||
|
|
|
@ -64,12 +64,10 @@ $lang = array_merge($lang, array(
|
|||
'FULLTEXT_POSTGRES_INCOMPATIBLE_VERSION' => 'The PostgreSQL fulltext backend can only be used with PostgreSQL.',
|
||||
'FULLTEXT_POSTGRES_TS_NOT_USABLE' => 'The PostgreSQL fulltext backend can only be used with PostgreSQL 8.3 and above.',
|
||||
'FULLTEXT_POSTGRES_TOTAL_POSTS' => 'Total number of indexed posts',
|
||||
'FULLTEXT_POSTGRES_MBSTRING' => 'Support for non-latin UTF-8 characters using mbstring:',
|
||||
'FULLTEXT_POSTGRES_PCRE' => 'Support for non-latin UTF-8 characters using PCRE:',
|
||||
'FULLTEXT_POSTGRES_TS_NAME' => 'Tsearch2 Configuration Profile:',
|
||||
'FULLTEXT_POSTGRES_MIN_WORD_LEN' => 'Minimum word length for keywords',
|
||||
'FULLTEXT_POSTGRES_MAX_WORD_LEN' => 'Maximum word length for keywords',
|
||||
'FULLTEXT_POSTGRES_MBSTRING_EXPLAIN' => 'If PCRE does not have unicode character properties, the search backend will try to use mbstring’s regular expression engine.',
|
||||
'FULLTEXT_POSTGRES_PCRE_EXPLAIN' => 'This search backend requires PCRE unicode character properties, only available in PHP 4.4, 5.1 and above, if you want to search for non-latin characters.',
|
||||
'FULLTEXT_POSTGRES_TS_NAME_EXPLAIN' => 'The Tsearch2 configuration profile used to determine the parser and dictionary.',
|
||||
'FULLTEXT_POSTGRES_MIN_WORD_LEN_EXPLAIN' => 'Words with at least this many characters will be included in the query to the database.',
|
||||
|
|
Loading…
Add table
Reference in a new issue