From 4257a918f30c05848c27f884c7f8463fa24bbb88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 8 Apr 2022 00:11:08 +0200 Subject: [PATCH] fix error when search pattern is empty --- src/Bundle/ChillMainBundle/Controller/SearchController.php | 2 +- .../Repository/PersonACLAwareRepository.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/SearchController.php b/src/Bundle/ChillMainBundle/Controller/SearchController.php index b9f5d19d8..41349336a 100644 --- a/src/Bundle/ChillMainBundle/Controller/SearchController.php +++ b/src/Bundle/ChillMainBundle/Controller/SearchController.php @@ -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) { diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php index 5ed9762c8..d5dc3cd7d 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php @@ -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 + " .