Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormacjohnny <estebanmarin@gmx.ch>2014-06-12 11:41:23 +0400
committerMorris Jobke <morris.jobke@gmail.com>2014-06-13 02:04:06 +0400
commit767aa4e35ff4d8c9bd61996b15b286a86a9f92db (patch)
treef31cdd287b7a5546cdf3c3a7b0e2f31d5ef0b9ce /lib/private/group
parentb595c982d0cc27c9e6e3ee3a04c8f9a567ec0dc8 (diff)
drastic speedup for nested ldap groups
add a function getUserGroupIds for retrieving group ids instead of group objects. this significantly improves performance when using many (nested) groups. Changes a function call in getUserGroups to only retrieve group ids instead of objects. this change significantly improves performance when using owncloud with many groups, e.g. nested ldap hierarchy (1.2.840.113556.1.4.1941), since getUserGroups gets called in oc_share::getItems, which is needed for every page request. in my particular case, it took more than 10s to load the calendar page and more than 6s to load the file page. this was in an environment with 100 user groups (nested) per user. The performance was bad due to the following call stack: self::getManager()->getUserGroups($user) - getGroupObject() (executed for every group!) - groupExists() (resulting in many ldap-requests) since the groups are loaded from ldap, it is unnecessary to check whether the group exists or not.
Diffstat (limited to 'lib/private/group')
-rw-r--r--lib/private/group/manager.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index dae6443e9d4..3613c7547bd 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -182,6 +182,18 @@ class Manager extends PublicEmitter {
$this->cachedUserGroups[$uid] = array_values($groups);
return $this->cachedUserGroups[$uid];
}
+ /**
+ * @param \OC\User\User $user
+ * @return array with group names
+ */
+ public function getUserGroupIds($user) {
+ $groupIds = array();
+ foreach ($this->backends as $backend) {
+ $groupIds = array_merge($groupIds, $backend->getUserGroups($user->getUID()));
+
+ }
+ return $groupIds;
+ }
/**
* get a list of all display names in a group