Merge pull request #9104 from macjohnny/macjohnny-drastic-ldap-speedup
drastic ldap speedup (update)
This commit is contained in:
commit
688a141586
2 changed files with 22 additions and 15 deletions
|
@ -48,6 +48,7 @@ class Manager extends PublicEmitter implements IGroupManager {
|
|||
*/
|
||||
private $cachedUserGroups = array();
|
||||
|
||||
|
||||
/**
|
||||
* @param \OC\User\Manager $userManager
|
||||
*/
|
||||
|
@ -180,18 +181,24 @@ class Manager extends PublicEmitter implements IGroupManager {
|
|||
$groups[$groupId] = $this->get($groupId);
|
||||
}
|
||||
}
|
||||
$this->cachedUserGroups[$uid] = array_values($groups);
|
||||
$this->cachedUserGroups[$uid] = $groups;
|
||||
return $this->cachedUserGroups[$uid];
|
||||
}
|
||||
|
||||
/**
|
||||
* get a list of group ids for a user
|
||||
* @param \OC\User\User $user
|
||||
* @return array with group names
|
||||
* @return array with group ids
|
||||
*/
|
||||
public function getUserGroupIds($user) {
|
||||
$groupIds = array();
|
||||
foreach ($this->backends as $backend) {
|
||||
$groupIds = array_merge($groupIds, $backend->getUserGroups($user->getUID()));
|
||||
|
||||
$userId = $user->getUID();
|
||||
if (isset($this->cachedUserGroups[$userId])) {
|
||||
return array_keys($this->cachedUserGroups[$userId]);
|
||||
} else {
|
||||
foreach ($this->backends as $backend) {
|
||||
$groupIds = array_merge($groupIds, $backend->getUserGroups($userId));
|
||||
}
|
||||
}
|
||||
return $groupIds;
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ class Manager extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
$groups = $manager->search('1');
|
||||
$this->assertEquals(1, count($groups));
|
||||
$group1 = $groups[0];
|
||||
$group1 = reset($groups);
|
||||
$this->assertEquals('group1', $group1->getGID());
|
||||
}
|
||||
|
||||
|
@ -229,8 +229,8 @@ class Manager extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
$groups = $manager->search('1');
|
||||
$this->assertEquals(2, count($groups));
|
||||
$group1 = $groups[0];
|
||||
$group12 = $groups[1];
|
||||
$group1 = reset($groups);
|
||||
$group12 = next($groups);
|
||||
$this->assertEquals('group1', $group1->getGID());
|
||||
$this->assertEquals('group12', $group12->getGID());
|
||||
}
|
||||
|
@ -270,8 +270,8 @@ class Manager extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
$groups = $manager->search('1', 2, 1);
|
||||
$this->assertEquals(2, count($groups));
|
||||
$group1 = $groups[0];
|
||||
$group12 = $groups[1];
|
||||
$group1 = reset($groups);
|
||||
$group12 = next($groups);
|
||||
$this->assertEquals('group1', $group1->getGID());
|
||||
$this->assertEquals('group12', $group12->getGID());
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ class Manager extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
$groups = $manager->getUserGroups(new User('user1', $userBackend));
|
||||
$this->assertEquals(1, count($groups));
|
||||
$group1 = $groups[0];
|
||||
$group1 = reset($groups);
|
||||
$this->assertEquals('group1', $group1->getGID());
|
||||
}
|
||||
|
||||
|
@ -340,8 +340,8 @@ class Manager extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
$groups = $manager->getUserGroups(new User('user1', $userBackend));
|
||||
$this->assertEquals(2, count($groups));
|
||||
$group1 = $groups[0];
|
||||
$group2 = $groups[1];
|
||||
$group1 = reset($groups);
|
||||
$group2 = next($groups);
|
||||
$this->assertEquals('group1', $group1->getGID());
|
||||
$this->assertEquals('group2', $group2->getGID());
|
||||
}
|
||||
|
@ -727,7 +727,7 @@ class Manager extends \PHPUnit_Framework_TestCase {
|
|||
// check result
|
||||
$groups = $manager->getUserGroups($user1);
|
||||
$this->assertEquals(1, count($groups));
|
||||
$group1 = $groups[0];
|
||||
$group1 = reset($groups);
|
||||
$this->assertEquals('group1', $group1->getGID());
|
||||
}
|
||||
|
||||
|
@ -768,7 +768,7 @@ class Manager extends \PHPUnit_Framework_TestCase {
|
|||
$user1 = new User('user1', null);
|
||||
$groups = $manager->getUserGroups($user1);
|
||||
$this->assertEquals(1, count($groups));
|
||||
$group1 = $groups[0];
|
||||
$group1 = reset($groups);
|
||||
$this->assertEquals('group1', $group1->getGID());
|
||||
|
||||
// remove user
|
||||
|
|
Loading…
Reference in a new issue