summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-05-26 10:38:17 +0200
committerGitHub <noreply@github.com>2020-05-26 10:38:17 +0200
commit3bf02858402a4520fb294eaef656b9863d1a2658 (patch)
tree8814480964cc012f2bdfde1d03c7e95d709ece10 /lib/private
parent9c63433cde916cd35b0708b398910cbc1cb52315 (diff)
parent444b28adf64bae9ea0ca9d08fb7d08fc6f7f38b0 (diff)
downloadnextcloud-server-3bf02858402a4520fb294eaef656b9863d1a2658.tar.gz
nextcloud-server-3bf02858402a4520fb294eaef656b9863d1a2658.zip
Merge pull request #21068 from nextcloud/backport/20776/stable19
[stable19] Improve group queries
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Group/Database.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/private/Group/Database.php b/lib/private/Group/Database.php
index 1202ba09b13..ec8f7ea6f53 100644
--- a/lib/private/Group/Database.php
+++ b/lib/private/Group/Database.php
@@ -118,7 +118,10 @@ class Database extends ABackend implements
}
// Add to cache
- $this->groupCache[$gid] = $gid;
+ $this->groupCache[$gid] = [
+ 'gid' => $gid,
+ 'displayname' => $gid
+ ];
return $result === 1;
}
@@ -244,15 +247,19 @@ class Database extends ABackend implements
// No magic!
$qb = $this->dbConn->getQueryBuilder();
- $cursor = $qb->select('gid')
- ->from('group_user')
+ $cursor = $qb->select('gu.gid', 'g.displayname')
+ ->from('group_user', 'gu')
+ ->leftJoin('gu', 'groups', 'g', $qb->expr()->eq('gu.gid', 'g.gid'))
->where($qb->expr()->eq('uid', $qb->createNamedParameter($uid)))
->execute();
$groups = [];
while ($row = $cursor->fetch()) {
$groups[] = $row['gid'];
- $this->groupCache[$row['gid']] = $row['gid'];
+ $this->groupCache[$row['gid']] = [
+ 'gid' => $row['gid'],
+ 'displayname' => $row['displayname'],
+ ];
}
$cursor->closeCursor();
@@ -309,7 +316,7 @@ class Database extends ABackend implements
}
$qb = $this->dbConn->getQueryBuilder();
- $cursor = $qb->select('gid')
+ $cursor = $qb->select('gid', 'displayname')
->from('groups')
->where($qb->expr()->eq('gid', $qb->createNamedParameter($gid)))
->execute();
@@ -317,7 +324,10 @@ class Database extends ABackend implements
$cursor->closeCursor();
if ($result !== false) {
- $this->groupCache[$gid] = $gid;
+ $this->groupCache[$gid] = [
+ 'gid' => $gid,
+ 'displayname' => $result['displayname'],
+ ];
return true;
}
return false;
@@ -430,6 +440,10 @@ class Database extends ABackend implements
}
public function getDisplayName(string $gid): string {
+ if (isset($this->groupCache[$gid])) {
+ return $this->groupCache[$gid]['displayname'];
+ }
+
$this->fixDI();
$query = $this->dbConn->getQueryBuilder();