diff options
| author | Dhruv Goel <dhruv.goel92@gmail.com> | 2012-06-12 04:18:39 +0530 |
|---|---|---|
| committer | Dhruv Goel <dhruv.goel92@gmail.com> | 2012-07-05 21:13:40 +0530 |
| commit | 84054afc9de614bb41f178f78a71c6966b9e0537 (patch) | |
| tree | 32c769f69e96e9a44dc14d835544a95c01ea90e6 /phpBB | |
| parent | 8981399ae141d87aaa2f2f7994bca9cf6df3ec24 (diff) | |
| download | forums-84054afc9de614bb41f178f78a71c6966b9e0537.tar forums-84054afc9de614bb41f178f78a71c6966b9e0537.tar.gz forums-84054afc9de614bb41f178f78a71c6966b9e0537.tar.bz2 forums-84054afc9de614bb41f178f78a71c6966b9e0537.tar.xz forums-84054afc9de614bb41f178f78a71c6966b9e0537.zip | |
[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
Diffstat (limited to 'phpBB')
| -rw-r--r-- | phpBB/includes/search/fulltext_postgres.php | 89 | ||||
| -rw-r--r-- | phpBB/language/en/acp/search.php | 2 |
2 files changed, 8 insertions, 83 deletions
diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php index 66208f35c7..f5d9b3c760 100644 --- a/phpBB/includes/search/fulltext_postgres.php +++ b/phpBB/includes/search/fulltext_postgres.php @@ -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]; - } + $split_keywords = preg_replace('#([^\p{L}\p{N}\'*"()])#u', '$1$1', str_replace('\'\'', '\' \'', trim($split_keywords))); + $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]; // 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]; - } + $text = preg_replace('#([^\p{L}\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text))); + $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]; // remove too short or too long words $text = array_values($text); @@ -859,10 +790,6 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base <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]">'; diff --git a/phpBB/language/en/acp/search.php b/phpBB/language/en/acp/search.php index a307bc3e07..6d45878038 100644 --- a/phpBB/language/en/acp/search.php +++ b/phpBB/language/en/acp/search.php @@ -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.', |
