]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(sharding): typo in addOrderBy backport/48559/stable30 49001/head
authorBenjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
Tue, 29 Oct 2024 10:32:14 +0000 (11:32 +0100)
committerBenjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
Wed, 30 Oct 2024 10:43:38 +0000 (11:43 +0100)
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php
lib/private/User/Manager.php

index e5b66470de08a93f6ef415800bb3423811efa106..4caab8aec15adc3787a139b442d6423ad1543fe5 100644 (file)
@@ -277,7 +277,7 @@ class ShardedQueryBuilder extends ExtendedQueryBuilder {
 
        public function addOrderBy($sort, $order = null) {
                $this->registerOrder((string)$sort, (string)$order ?? 'ASC');
-               return parent::orderBy($sort, $order);
+               return parent::addOrderBy($sort, $order);
        }
 
        public function orderBy($sort, $order = null) {
index 5e99107e5047794a8abc541dc5139e0f7c0deb76..2ca0359e4d441138fb6323eedea882f2f71dcb32 100644 (file)
@@ -754,27 +754,10 @@ class Manager extends PublicEmitter implements IUserManager {
 
                $connection = \OC::$server->getDatabaseConnection();
                $queryBuilder = $connection->getQueryBuilder();
-               $queryBuilder->selectDistinct('uid')
-                       ->from('users', 'u')
-                       ->leftJoin('u', 'preferences', 'p', $queryBuilder->expr()->andX(
-                               $queryBuilder->expr()->eq('p.userid', 'uid'),
-                               $queryBuilder->expr()->eq('p.appid', $queryBuilder->expr()->literal('login')),
-                               $queryBuilder->expr()->eq('p.configkey', $queryBuilder->expr()->literal('lastLogin')))
-                       );
-               if($search !== '') {
-                       $queryBuilder->leftJoin('u', 'preferences', 'p1', $queryBuilder->expr()->andX(
-                               $queryBuilder->expr()->eq('p1.userid', 'uid'),
-                               $queryBuilder->expr()->eq('p1.appid', $queryBuilder->expr()->literal('settings')),
-                               $queryBuilder->expr()->eq('p1.configkey', $queryBuilder->expr()->literal('email')))
-                       )
-                               // sqlite doesn't like re-using a single named parameter here
-                               ->where($queryBuilder->expr()->iLike('uid', $queryBuilder->createPositionalParameter('%' . $connection->escapeLikeParameter($search) . '%')))
-                               ->orWhere($queryBuilder->expr()->iLike('displayname', $queryBuilder->createPositionalParameter('%' . $connection->escapeLikeParameter($search) . '%')))
-                               ->orWhere($queryBuilder->expr()->iLike('p1.configvalue', $queryBuilder->createPositionalParameter('%' . $connection->escapeLikeParameter($search) . '%'))
-                               );
-               }
-               $queryBuilder->orderBy($queryBuilder->func()->lower('p.configvalue'), 'DESC')
-                       ->addOrderBy('uid_lower', 'ASC')
+               $queryBuilder->select('pref_login.userid')
+                       ->from('preferences', 'pref_login')
+                       ->where($queryBuilder->expr()->eq('pref_login.appid', $queryBuilder->expr()->literal('login')))
+                       ->andWhere($queryBuilder->expr()->eq('pref_login.configkey', $queryBuilder->expr()->literal('lastLogin')))
                        ->setFirstResult($offset)
                        ->setMaxResults($limit)
                ;