mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 12:28:52 +00:00
- use constants no weird numbers ;-)
- solved problem with \w using UTF-8 search (fulltext_mysql) by using PCRE unicode character properties if available [Bug #5768] git-svn-id: file:///svn/phpbb/trunk@6843 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
77335d94e4
commit
ce13b9b996
2 changed files with 11 additions and 5 deletions
|
@ -2338,7 +2338,7 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb
|
||||||
$uid = '';
|
$uid = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$flags = (($allow_bbcode) ? 1 : 0) + (($allow_smilies) ? 2 : 0) + (($allow_urls) ? 4 : 0);
|
$flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0);
|
||||||
$bitfield = $message_parser->bbcode_bitfield;
|
$bitfield = $message_parser->bbcode_bitfield;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -32,6 +32,7 @@ class fulltext_mysql extends search_backend
|
||||||
var $split_words = array();
|
var $split_words = array();
|
||||||
var $search_query;
|
var $search_query;
|
||||||
var $common_words = array();
|
var $common_words = array();
|
||||||
|
var $pcre_properties = false;
|
||||||
|
|
||||||
function fulltext_mysql(&$error)
|
function fulltext_mysql(&$error)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +40,11 @@ class fulltext_mysql extends search_backend
|
||||||
|
|
||||||
$this->word_length = array('min' => $config['fulltext_mysql_min_word_len'], 'max' => $config['fulltext_mysql_max_word_len']);
|
$this->word_length = array('min' => $config['fulltext_mysql_min_word_len'], 'max' => $config['fulltext_mysql_max_word_len']);
|
||||||
|
|
||||||
|
if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>=')))
|
||||||
|
{
|
||||||
|
$this->pcre_properties = true;
|
||||||
|
}
|
||||||
|
|
||||||
$error = false;
|
$error = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,9 +129,9 @@ class fulltext_mysql extends search_backend
|
||||||
$keywords = preg_replace($match, ' ', trim($keywords));
|
$keywords = preg_replace($match, ' ', trim($keywords));
|
||||||
|
|
||||||
// Split words
|
// Split words
|
||||||
$split_keywords = preg_replace('#([^\w\'*])#', '$1$1', str_replace('\'\'', '\' \'', trim($keywords)));
|
$split_keywords = preg_replace(($this->pcre_properties) ? '#([^\p{L}\p{N}\'*])#u' : '#([^\w\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($keywords)));
|
||||||
$matches = array();
|
$matches = array();
|
||||||
preg_match_all('#(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)#', $split_keywords, $matches);
|
preg_match_all(($this->pcre_properties) ? '#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u' : '#(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)#u', $split_keywords, $matches);
|
||||||
$this->split_words = $matches[1];
|
$this->split_words = $matches[1];
|
||||||
|
|
||||||
if (sizeof($this->ignore_words))
|
if (sizeof($this->ignore_words))
|
||||||
|
@ -174,9 +180,9 @@ class fulltext_mysql extends search_backend
|
||||||
$this->get_synonyms();
|
$this->get_synonyms();
|
||||||
|
|
||||||
// Split words
|
// Split words
|
||||||
$text = preg_replace('#([^\w\'*])#', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
|
$text = preg_replace(($this->pcre_properties) ? '#([^\p{L}\p{N}\'*])#u' : '#([^\w\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
|
||||||
$matches = array();
|
$matches = array();
|
||||||
preg_match_all('#(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)#', $text, $matches);
|
preg_match_all(($this->pcre_properties) ? '#(?:[^\p{L}\p{N}*]|^)([+\-|]?(?:[\p{L}\p{N}*]+\'?)*[\p{L}\p{N}*])(?:[^\p{L}\p{N}*]|$)#u' : '#(?:[^\w*]|^)([+\-|]?(?:[\w*]+\'?)*[\w*])(?:[^\w*]|$)#u', $text, $matches);
|
||||||
$text = $matches[1];
|
$text = $matches[1];
|
||||||
|
|
||||||
if (sizeof($this->ignore_words))
|
if (sizeof($this->ignore_words))
|
||||||
|
|
Loading…
Add table
Reference in a new issue