From d05dca0c1c7f737f2b2dfc8c044a583b0a07c035 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 18 Mar 2022 09:22:16 +0100 Subject: Simplify comment search in special cases Signed-off-by: Joas Schilling --- lib/private/Comments/Manager.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/private/Comments/Manager.php') diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index 7c312b18f7d..384187accf3 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -611,13 +611,16 @@ class Manager implements ICommentsManager { $query->select('*') ->from('comments') - ->where($query->expr()->iLike('message', $query->createNamedParameter( - '%' . $this->dbConn->escapeLikeParameter($search). '%' - ))) ->orderBy('creation_timestamp', 'DESC') ->addOrderBy('id', 'DESC') ->setMaxResults($limit); + if ($search !== '') { + $query->where($query->expr()->iLike('message', $query->createNamedParameter( + '%' . $this->dbConn->escapeLikeParameter($search). '%' + ))); + } + if ($objectType !== '') { $query->andWhere($query->expr()->eq('object_type', $query->createNamedParameter($objectType))); } -- cgit v1.2.3