fix error when search pattern is empty

This commit is contained in:
Julien Fastré 2022-04-08 00:11:08 +02:00
parent 7ffb3dc74f
commit 4257a918f3
2 changed files with 5 additions and 2 deletions

View File

@ -122,7 +122,7 @@ class SearchController extends AbstractController
public function searchAction(Request $request, $_format)
{
$pattern = $request->query->get('q', '');
$pattern = trim($request->query->get('q', ''));
if ('' === $pattern) {
switch ($_format) {

View File

@ -136,8 +136,11 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac
$andWhereSearchClause = [];
$andWhereSearchClauseArgs = [];
if ('' !== $default) {
if ('' !== trim($default)) {
foreach (explode(' ', $default) as $str) {
if ('' === trim($str)) {
continue;
}
$pertinence[] =
'STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), person.fullnamecanonical) + ' .
"(person.fullnamecanonical LIKE '%' || LOWER(UNACCENT(?)) || '%')::int + " .