diff options
author | Joas Schilling <coding@schilljs.com> | 2022-03-18 09:22:16 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-03-18 09:22:16 +0100 |
commit | d05dca0c1c7f737f2b2dfc8c044a583b0a07c035 (patch) | |
tree | 5f1c43320b6c559100367e4271e6e2045ecef092 /lib/private/Comments | |
parent | b0fbcccfe66474d79586001ce9509d346919ae74 (diff) | |
download | nextcloud-server-d05dca0c1c7f737f2b2dfc8c044a583b0a07c035.tar.gz nextcloud-server-d05dca0c1c7f737f2b2dfc8c044a583b0a07c035.zip |
Simplify comment search in special cases
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r-- | lib/private/Comments/Manager.php | 9 |
1 files changed, 6 insertions, 3 deletions
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))); } |