diff options
Diffstat (limited to 'phpBB/phpbb/search')
| -rw-r--r-- | phpBB/phpbb/search/fulltext_mysql.php | 6 | ||||
| -rw-r--r-- | phpBB/phpbb/search/fulltext_native.php | 40 | ||||
| -rw-r--r-- | phpBB/phpbb/search/fulltext_postgres.php | 2 | ||||
| -rw-r--r-- | phpBB/phpbb/search/fulltext_sphinx.php | 17 | 
4 files changed, 33 insertions, 32 deletions
| diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php index 3ddbd85b36..d1962bc8cc 100644 --- a/phpBB/phpbb/search/fulltext_mysql.php +++ b/phpBB/phpbb/search/fulltext_mysql.php @@ -196,8 +196,8 @@ class fulltext_mysql extends \phpbb\search\base  		}  		$this->db->sql_freeresult($result); -		set_config('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']); -		set_config('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']); +		$this->config->set('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']); +		$this->config->set('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']);  		return false;  	} @@ -919,7 +919,7 @@ class fulltext_mysql extends \phpbb\search\base  		// destroy too old cached search results  		$this->destroy_cache(array()); -		set_config('search_last_gc', time(), true); +		$this->config->set('search_last_gc', time(), false);  	}  	/** diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php index a02f889415..3a74955a18 100644 --- a/phpBB/phpbb/search/fulltext_native.php +++ b/phpBB/phpbb/search/fulltext_native.php @@ -18,6 +18,13 @@ namespace phpbb\search;  */  class fulltext_native extends \phpbb\search\base  { +	const UTF8_HANGUL_FIRST = "\xEA\xB0\x80"; +	const UTF8_HANGUL_LAST = "\xED\x9E\xA3"; +	const UTF8_CJK_FIRST = "\xE4\xB8\x80"; +	const UTF8_CJK_LAST = "\xE9\xBE\xBB"; +	const UTF8_CJK_B_FIRST = "\xF0\xA0\x80\x80"; +	const UTF8_CJK_B_LAST = "\xF0\xAA\x9B\x96"; +  	/**  	 * Associative array holding index stats  	 * @var array @@ -99,7 +106,7 @@ class fulltext_native extends \phpbb\search\base  	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  	*  	* @param	boolean|string	&$error	is passed by reference and should either be set to false on success or an error message on failure  	* @param	\phpbb\event\dispatcher_interface	$phpbb_dispatcher	Event dispatcher object @@ -118,10 +125,6 @@ class fulltext_native extends \phpbb\search\base  		/**  		* Load the UTF tools  		*/ -		if (!class_exists('utf_normalizer')) -		{ -			include($this->phpbb_root_path . 'includes/utf/utf_normalizer.' . $this->php_ext); -		}  		if (!function_exists('utf8_decode_ncr'))  		{  			include($this->phpbb_root_path . 'includes/utf/utf_tools.' . $this->php_ext); @@ -1361,9 +1364,9 @@ class fulltext_native extends \phpbb\search\base  				* Note: this could be optimized. If the codepoint is lower than Hangul's range  				* we know that it will also be lower than CJK ranges  				*/ -				if ((strncmp($word, UTF8_HANGUL_FIRST, 3) < 0 || strncmp($word, UTF8_HANGUL_LAST, 3) > 0) -					&& (strncmp($word, UTF8_CJK_FIRST, 3) < 0 || strncmp($word, UTF8_CJK_LAST, 3) > 0) -					&& (strncmp($word, UTF8_CJK_B_FIRST, 4) < 0 || strncmp($word, UTF8_CJK_B_LAST, 4) > 0)) +				if ((strncmp($word, self::UTF8_HANGUL_FIRST, 3) < 0 || strncmp($word, self::UTF8_HANGUL_LAST, 3) > 0) +					&& (strncmp($word, self::UTF8_CJK_FIRST, 3) < 0 || strncmp($word, self::UTF8_CJK_LAST, 3) > 0) +					&& (strncmp($word, self::UTF8_CJK_B_FIRST, 4) < 0 || strncmp($word, self::UTF8_CJK_B_LAST, 4) > 0))  				{  					$word = strtok(' ');  					continue; @@ -1608,7 +1611,7 @@ class fulltext_native extends \phpbb\search\base  		// carry on ... it's okay ... I know when I'm not wanted boo hoo  		if (!$this->config['fulltext_native_load_upd'])  		{ -			set_config('search_last_gc', time(), true); +			$this->config->set('search_last_gc', time(), false);  			return;  		} @@ -1643,7 +1646,7 @@ class fulltext_native extends \phpbb\search\base  				// by setting search_last_gc to the new time here we make sure that if a user reloads because the  				// following query takes too long, he won't run into it again -				set_config('search_last_gc', time(), true); +				$this->config->set('search_last_gc', time(), false);  				// Delete the matches  				$sql = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE . ' @@ -1659,7 +1662,7 @@ class fulltext_native extends \phpbb\search\base  			$this->destroy_cache(array_unique($destroy_cache_words));  		} -		set_config('search_last_gc', time(), true); +		$this->config->set('search_last_gc', time(), false);  	}  	/** @@ -1730,8 +1733,6 @@ class fulltext_native extends \phpbb\search\base  	* @param	string	$allowed_chars	String of special chars to allow  	* @param	string	$encoding		Text encoding  	* @return	string					Cleaned up text, only alphanumeric chars are left -	* -	* @todo \normalizer::cleanup being able to be used?  	*/  	protected function cleanup($text, $allowed_chars = null, $encoding = 'utf-8')  	{ @@ -1758,12 +1759,9 @@ class fulltext_native extends \phpbb\search\base  		$text = htmlspecialchars_decode(utf8_decode_ncr($text), ENT_QUOTES);  		/** -		* Load the UTF-8 normalizer -		* -		* If we use it more widely, an instance of that class should be held in a -		* a global variable instead +		* Normalize to NFC  		*/ -		\utf_normalizer::nfc($text); +		$text = \Normalizer::normalize($text);  		/**  		* The first thing we do is: @@ -1856,9 +1854,9 @@ class fulltext_native extends \phpbb\search\base  			$utf_char = substr($text, $pos, $utf_len);  			$pos += $utf_len; -			if (($utf_char >= UTF8_HANGUL_FIRST && $utf_char <= UTF8_HANGUL_LAST) -				|| ($utf_char >= UTF8_CJK_FIRST && $utf_char <= UTF8_CJK_LAST) -				|| ($utf_char >= UTF8_CJK_B_FIRST && $utf_char <= UTF8_CJK_B_LAST)) +			if (($utf_char >= self::UTF8_HANGUL_FIRST && $utf_char <= self::UTF8_HANGUL_LAST) +				|| ($utf_char >= self::UTF8_CJK_FIRST && $utf_char <= self::UTF8_CJK_LAST) +				|| ($utf_char >= self::UTF8_CJK_B_FIRST && $utf_char <= self::UTF8_CJK_B_LAST))  			{  				/**  				* All characters within these ranges are valid diff --git a/phpBB/phpbb/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php index c2186b0df3..ab28fd2957 100644 --- a/phpBB/phpbb/search/fulltext_postgres.php +++ b/phpBB/phpbb/search/fulltext_postgres.php @@ -916,7 +916,7 @@ class fulltext_postgres extends \phpbb\search\base  		// destroy too old cached search results  		$this->destroy_cache(array()); -		set_config('search_last_gc', time(), true); +		$this->config->set('search_last_gc', time(), false);  	}  	/** diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php index 612ef8f1f3..372a2792cf 100644 --- a/phpBB/phpbb/search/fulltext_sphinx.php +++ b/phpBB/phpbb/search/fulltext_sphinx.php @@ -85,7 +85,7 @@ class fulltext_sphinx  	/**  	 * Database Tools object -	 * @var \phpbb\db\tools +	 * @var \phpbb\db\tools\tools_interface  	 */  	protected $db_tools; @@ -143,12 +143,13 @@ class fulltext_sphinx  		$this->db = $db;  		$this->auth = $auth; -		// Initialize \phpbb\db\tools object -		$this->db_tools = new \phpbb\db\tools($this->db); +		// Initialize \phpbb\db\tools\tools object +		global $phpbb_container; // TODO inject into object +		$this->db_tools = $phpbb_container->get('dbal.tools');  		if (!$this->config['fulltext_sphinx_id'])  		{ -			set_config('fulltext_sphinx_id', unique_id()); +			$this->config->set('fulltext_sphinx_id', unique_id());  		}  		$this->id = $this->config['fulltext_sphinx_id'];  		$this->indexes = 'index_phpbb_' . $this->id . '_delta;index_phpbb_' . $this->id . '_main'; @@ -219,7 +220,7 @@ class fulltext_sphinx  		}  		// Move delta to main index each hour -		set_config('search_gc', 3600); +		$this->config->set('search_gc', 3600);  		return false;  	} @@ -479,6 +480,8 @@ class fulltext_sphinx  	*/  	public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page)  	{ +		global $user, $phpbb_log; +  		// No keywords? No posts.  		if (!strlen($this->search_query) && !sizeof($author_ary))  		{ @@ -661,7 +664,7 @@ class fulltext_sphinx  		if ($this->sphinx->GetLastError())  		{ -			add_log('critical', 'LOG_SPHINX_ERROR', $this->sphinx->GetLastError()); +			$phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_SPHINX_ERROR', false, array($this->sphinx->GetLastError()));  			if ($this->auth->acl_get('a_'))  			{  				trigger_error($this->user->lang('SPHINX_SEARCH_FAILED', $this->sphinx->GetLastError())); @@ -815,7 +818,7 @@ class fulltext_sphinx  	*/  	public function tidy($create = false)  	{ -		set_config('search_last_gc', time(), true); +		$this->config->set('search_last_gc', time(), false);  	}  	/** | 
