When we iterate over all users that might be too much memory

This commit is contained in:
Joas Schilling 2016-04-28 12:26:48 +02:00
parent 13ea66e791
commit bbcef57d2a
No known key found for this signature in database
GPG Key ID: 70A0B324C41C0946
1 changed files with 9 additions and 4 deletions

View File

@ -147,14 +147,19 @@ class Manager extends PublicEmitter implements IUserManager {
*
* @param string $uid
* @param \OCP\UserInterface $backend
* @param bool $cacheUser If false the newly created user object will not be cached
* @return \OC\User\User
*/
protected function getUserObject($uid, $backend) {
protected function getUserObject($uid, $backend, $cacheUser = true) {
if (isset($this->cachedUsers[$uid])) {
return $this->cachedUsers[$uid];
}
$this->cachedUsers[$uid] = new User($uid, $backend, $this, $this->config);
return $this->cachedUsers[$uid];
$user = new User($uid, $backend, $this, $this->config);
if ($cacheUser) {
$this->cachedUsers[$uid] = $user;
}
return $user;
}
/**
@ -339,7 +344,7 @@ class Manager extends PublicEmitter implements IUserManager {
if (!$backend->userExists($uid)) {
continue;
}
$user = $this->getUserObject($uid, $backend);
$user = $this->getUserObject($uid, $backend, false);
$return = $callback($user);
if ($return === false) {
break;