diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-05-02 13:12:43 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-05-02 13:12:43 +0200 |
commit | d7eb17bdc023c6e31d24a0636e0f5cad58aa876f (patch) | |
tree | 4cce536d5cb9ae460a7393b9ffe6a7dfd29783d8 | |
parent | b8650be73295336b74a606e3bc567a13e81cfc83 (diff) | |
parent | b8114bcc33f78160b298d7a338a6a680d5ee077e (diff) | |
download | nextcloud-server-d7eb17bdc023c6e31d24a0636e0f5cad58aa876f.tar.gz nextcloud-server-d7eb17bdc023c6e31d24a0636e0f5cad58aa876f.zip |
Merge pull request #24327 from owncloud/better-callForAllUsers-performance
Better callForAllUsers memory usage
-rw-r--r-- | lib/private/user/manager.php | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php index 7967f877024..4371be134aa 100644 --- a/lib/private/user/manager.php +++ b/lib/private/user/manager.php @@ -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; } /** @@ -335,11 +340,11 @@ class Manager extends PublicEmitter implements IUserManager { $offset = 0; do { $users = $backend->getUsers($search, $limit, $offset); - foreach ($users as $user) { - $user = $this->get($user); - if (is_null($user)) { + foreach ($users as $uid) { + if (!$backend->userExists($uid)) { continue; } + $user = $this->getUserObject($uid, $backend, false); $return = $callback($user); if ($return === false) { break; |