From 22417e3d9cd522787f4b37e9b5208f7533dcb3e7 Mon Sep 17 00:00:00 2001
From: KYPREO <58344533+KYPREO@users.noreply.github.com>
Date: Sat, 4 Jan 2020 04:15:10 +1100
Subject: [PATCH] [ticket/16234] Fix & enhance Sphinx search backend
 functionality

PHPBB3-16234
PHPBB3-16233
PHPBB3-15367
PHPBB3-13958
---
 phpBB/phpbb/search/fulltext_sphinx.php | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php
index 196ab96505..dc784ef0e1 100644
--- a/phpBB/phpbb/search/fulltext_sphinx.php
+++ b/phpBB/phpbb/search/fulltext_sphinx.php
@@ -436,21 +436,21 @@ class fulltext_sphinx
 	public function split_keywords(&$keywords, $terms)
 	{
 		// Keep quotes and new lines
-		$keywords = str_replace(array['&quot;', "\n"], array['"', ' '], trim($keywords));
+		$keywords = str_replace(['&quot;', "\n"], ['"', ' '], trim($keywords));
 
 		if ($terms == 'all')
 		{
 			// Replaces verbal operators OR and NOT with special characters | and -, unless appearing within quotation marks
-			$match		= array['#\sor\s(?=([^"]*"[^"]*")*[^"]*$)#i', '#\snot\s(?=([^"]*"[^"]*")*[^"]*$)#i'];
-			$replace	= array[' | ', ' -'];
+			$match		= ['#\sor\s(?=([^"]*"[^"]*")*[^"]*$)#i', '#\snot\s(?=([^"]*"[^"]*")*[^"]*$)#i'];
+			$replace	= [' | ', ' -'];
 
 			$keywords = preg_replace($match, $replace, $keywords);
 			$this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED);
 		}
 		else
 		{
-			$match = array['\\', '(',')','|','!','@','~', '/', '^', '$', '=','&amp;', '&lt;', '&gt;'];
-			$replace = array[' ', ' ', ' ', ' ',' ',' ',' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '];
+			$match = ['\\', '(',')','|','!','@','~', '/', '^', '$', '=','&amp;', '&lt;', '&gt;'];
+			$replace = [' ', ' ', ' ', ' ',' ',' ',' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '];
 
 			$keywords = str_replace($match, $replace, $keywords);
 			$this->sphinx->SetMatchMode(SPH_MATCH_ANY);
@@ -497,17 +497,17 @@ class fulltext_sphinx
 	*/
 	public function sphinx_clean_search_string($search_string)
 	{
-		$from = array['@', '^', '$', '!', '&lt;', '&gt;', '&quot;', '&amp;', '\''];
-		$to = array['\@', '\^', '\$', '\!', '<', '>', '"', '&', ''];
+		$from = ['@', '^', '$', '!', '&lt;', '&gt;', '&quot;', '&amp;', '\''];
+		$to = ['\@', '\^', '\$', '\!', '<', '>', '"', '&', ''];
 
 		$search_string = str_replace($from, $to, $search_string);
 
 		$search_string = strrev($search_string);
-		$search_string = preg_replace(array['#\/(?!"[^"]+")#', '#~(?!"[^"]+")#'], array['/\\', '~\\'], $search_string);
+		$search_string = preg_replace(['#\/(?!"[^"]+")#', '#~(?!"[^"]+")#'], ['/\\', '~\\'], $search_string);
 		$search_string = strrev($search_string);
 
-		$match = array['#(/|\\\\/)(?![1-9](\s|$))#', '#(~|\\\\~)(?!\d{1,2}(\s|$))#', '#((?:\p{L}|\p{N})+)-((?:\p{L}|\p{N})+)(?:-((?:\p{L}|\p{N})+))?(?:-((?:\p{L}|\p{N})+))?#i', '#<<\s*$#', '#(\S\K=|=(?=\s)|=$)#'];
-		$replace = array['\/', '\~', '("$1 $2 $3 $4"|$1$2$3$4*)', '\<\<', '\='];
+		$match = ['#(/|\\\\/)(?![1-9](\s|$))#', '#(~|\\\\~)(?!\d{1,2}(\s|$))#', '#((?:\p{L}|\p{N})+)-((?:\p{L}|\p{N})+)(?:-((?:\p{L}|\p{N})+))?(?:-((?:\p{L}|\p{N})+))?#i', '#<<\s*$#', '#(\S\K=|=(?=\s)|=$)#'];
+		$replace = ['\/', '\~', '("$1 $2 $3 $4"|$1$2$3$4*)', '\<\<', '\='];
 
 		$search_string = preg_replace($match, $replace, $search_string);
 		$search_string = preg_replace('#\s+"\|#', '"|', $search_string);