Issue Bug Closed

#87620ContentObjectRenderer->searchWhere will do exception with too short word.

Alexey Atsyn 02/01/19, 16:06 updated 12/23/19, 22:48

Description

If a $searchWords is one word with length less then three digits result query will be broken.

#line: 7023
        foreach ($searchWords as $searchWord) {
            $searchWord = trim($searchWord);
            if (strlen($searchWord) < 3) {//TODO code will do that
                continue;
            }
            $searchWordConstraint = $queryBuilder->expr()->orX();
            $searchWord = $queryBuilder->escapeLikeWildcards($searchWord);
            foreach ($searchFields as $field) {
                $searchWordConstraint->add(
                    $queryBuilder->expr()->like($prefixTableName . $field, $queryBuilder->quote('%' . $searchWord . '%'))
                );
            }

            if ($searchWordConstraint->count()) {
                $where->add($searchWordConstraint);//TODO And this code will never be called
            }
        }

        return ' AND ' . (string)$where;

In the result we will get ‘ AND ‘ in any query it will call fatal error.

Reviews 2