Skip to content

Commit

Permalink
text filter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yurikuzn committed Jul 13, 2018
1 parent 31a6143 commit 1de98d9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions application/Espo/Core/SelectManagers/Base.php
Expand Up @@ -392,7 +392,8 @@ public function applyInCategory($link, $value, &$result)
protected function q($params, &$result)
{
if (isset($params['q']) && $params['q'] !== '') {
$this->textFilter($params['q'], $result);
$textFilter = $params['q'];
$this->textFilter($textFilter, $result);
}
}

Expand Down Expand Up @@ -1535,7 +1536,8 @@ public function getFullTextSearchDataForTextFilter($textFilter, $isAuxiliaryUse
if (!$fullTextSearchMinLength) {
$fullTextSearchMinLength = 0;
}
if (mb_strlen($textFilter) >= $fullTextSearchMinLength) {
$textFilterWoWildcards = str_replace('*', '', $textFilter);
if (mb_strlen($textFilterWoWildcards) >= $fullTextSearchMinLength) {
$useFullTextSearch = true;
}
}
Expand All @@ -1562,7 +1564,7 @@ public function getFullTextSearchDataForTextFilter($textFilter, $isAuxiliaryUse

if ($useFullTextSearch) {
if (
$isAuxiliaryUse
$isAuxiliaryUse && mb_strpos($textFilter, '*') === false
||
mb_strpos($textFilter, ' ') === false
&&
Expand Down Expand Up @@ -1617,15 +1619,21 @@ protected function textFilter($textFilter, &$result)
$forceFullTextSearch = true;
}

$textFilterForFullTextSearch = $textFilter;

$skipWidlcards = false;
if (!$useFullTextSearch) {
if (mb_strpos($textFilter, '*') !== false) {
$skipWidlcards = true;
$textFilter = str_replace('*', '%', $textFilter);
} else {
$textFilterForFullTextSearch .= '*';
}

$textFilterForFullTextSearch = str_replace('%', '*', $textFilterForFullTextSearch);
}

$fullTextSearchData = $this->getFullTextSearchDataForTextFilter($textFilter, !$useFullTextSearch);
$fullTextSearchData = $this->getFullTextSearchDataForTextFilter($textFilterForFullTextSearch, !$useFullTextSearch);

$fullTextGroup = [];

Expand Down

0 comments on commit 1de98d9

Please sign in to comment.