]> source.dussan.org Git - nextcloud-server.git/commitdiff
Simplify comment search in special cases 31614/head
authorJoas Schilling <coding@schilljs.com>
Fri, 18 Mar 2022 08:22:16 +0000 (09:22 +0100)
committerJoas Schilling <coding@schilljs.com>
Fri, 18 Mar 2022 08:22:16 +0000 (09:22 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Comments/Manager.php

index 7c312b18f7d2a1f16a34d6f8ab392507e7a094a5..384187accf33b1aec94929fdd18611edf1cec575 100644 (file)
@@ -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)));
                }