diff options
author | yemkareems <yemkareems@gmail.com> | 2024-07-04 18:18:06 +0530 |
---|---|---|
committer | yemkareems <yemkareems@gmail.com> | 2024-07-08 15:42:55 +0530 |
commit | 3dee8a213db5cb44a5c37e14cf71d82182aa54e9 (patch) | |
tree | 58c6c7629edcae9a60b9c7a91925a0cf4c13aced /lib/private | |
parent | 0e6040289f05b80501d6610977b6da8ec157b763 (diff) | |
download | nextcloud-server-3dee8a213db5cb44a5c37e14cf71d82182aa54e9.tar.gz nextcloud-server-3dee8a213db5cb44a5c37e14cf71d82182aa54e9.zip |
fix: second join and where conditions added only when search param is available
Signed-off-by: yemkareems <yemkareems@gmail.com>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/AllConfig.php | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php index 398ac9a6567..0d7973ab0e5 100644 --- a/lib/private/AllConfig.php +++ b/lib/private/AllConfig.php @@ -504,23 +504,26 @@ class AllConfig implements IConfig { $this->fixDIInit(); $query = $this->connection->getQueryBuilder(); - $query->selectDistinct('uid') ->from('users', 'u') ->leftJoin('u', 'preferences', 'p', $query->expr()->andX( $query->expr()->eq('p.userid', 'uid'), $query->expr()->eq('p.appid', $query->expr()->literal('login')), $query->expr()->eq('p.configkey', $query->expr()->literal('lastLogin'))) - )->leftJoin('u', 'preferences', 'p1', $query->expr()->andX( - $query->expr()->eq('p1.userid', 'uid'), - $query->expr()->eq('p1.appid', $query->expr()->literal('settings')), - $query->expr()->eq('p1.configkey', $query->expr()->literal('email'))) - ) - // sqlite doesn't like re-using a single named parameter here - ->where($query->expr()->iLike('uid', $query->createPositionalParameter('%' . $this->connection->escapeLikeParameter($search) . '%'))) - ->orWhere($query->expr()->iLike('displayname', $query->createPositionalParameter('%' . $this->connection->escapeLikeParameter($search) . '%'))) - ->orWhere($query->expr()->iLike('p1.configvalue', $query->createPositionalParameter('%' . $this->connection->escapeLikeParameter($search) . '%'))) - ->orderBy($query->func()->lower('p.configvalue'), 'DESC') + ); + if($search !== '') { + $query->leftJoin('u', 'preferences', 'p1', $query->expr()->andX( + $query->expr()->eq('p1.userid', 'uid'), + $query->expr()->eq('p1.appid', $query->expr()->literal('settings')), + $query->expr()->eq('p1.configkey', $query->expr()->literal('email'))) + ) + // sqlite doesn't like re-using a single named parameter here + ->where($query->expr()->iLike('uid', $query->createPositionalParameter('%' . $this->connection->escapeLikeParameter($search) . '%'))) + ->orWhere($query->expr()->iLike('displayname', $query->createPositionalParameter('%' . $this->connection->escapeLikeParameter($search) . '%'))) + ->orWhere($query->expr()->iLike('p1.configvalue', $query->createPositionalParameter('%' . $this->connection->escapeLikeParameter($search) . '%')) + ); + } + $query->orderBy($query->func()->lower('p.configvalue'), 'DESC') ->addOrderBy('uid_lower', 'ASC') ->setFirstResult($offset) ->setMaxResults($limit); |