From 873d109b989051a6922f76d87c3b9211bf1b54ae Mon Sep 17 00:00:00 2001 From: acognet Date: Tue, 12 May 2020 14:47:41 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B01910=20-=20iTop=20-=20Search=20on=20Text?= =?UTF-8?q?=20contains=20"=5F"=20not=20working=20-=20move=20correction=20i?= =?UTF-8?q?n=20other=20place?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/dbobjectsearch.class.php | 5 ++++- pages/UI.php | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/dbobjectsearch.class.php b/core/dbobjectsearch.class.php index 5bf9cb8dd..95a78010d 100644 --- a/core/dbobjectsearch.class.php +++ b/core/dbobjectsearch.class.php @@ -632,7 +632,10 @@ class DBObjectSearch extends DBSearch $oNewCond = new BinaryExpression($oTextFields, 'LIKE', $oFlexNeedle); $this->AddConditionExpression($oNewCond); - $this->m_aParams[$sQueryParam] = $sNeedle; + //replace in order to search the character "_" ("_" in mysql is like "%" for only one character). + $sFullText = str_replace('_', '\_', $sNeedle); + + $this->m_aParams[$sQueryParam] = $sFullText; } protected function AddToNameSpace(&$aClassAliases, &$aAliasTranslation, $bTranslateMainAlias = true) diff --git a/pages/UI.php b/pages/UI.php index 0bdd5881c..a67630b50 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -568,7 +568,6 @@ try $sFullText = trim($aMatches[2]); } } - $sFullText = str_replace('_', '\_', $sFullText); if (preg_match('/^"(.*)"$/', $sFullText, $aMatches)) { // The text is surrounded by double-quotes, remove the quotes and treat it as one single expression @@ -600,7 +599,7 @@ try break; } $sFullText = implode(' ', $aFullTextNeedles); - $sFullText = str_replace('\_', '_', $sFullText); + // Sanity check of the accelerators /** @var array $aAccelerators */ $aAccelerators = MetaModel::GetConfig()->Get('full_text_accelerators');