Merge pull request #24384 from owncloud/backport-24327-memory-usage-in-callForAllUsers
[9.0] Better callForAllUsers memory usage
This commit is contained in:
commit
d7da0ac1dc
|
@ -147,14 +147,19 @@ class Manager extends PublicEmitter implements IUserManager {
|
||||||
*
|
*
|
||||||
* @param string $uid
|
* @param string $uid
|
||||||
* @param \OCP\UserInterface $backend
|
* @param \OCP\UserInterface $backend
|
||||||
|
* @param bool $cacheUser If false the newly created user object will not be cached
|
||||||
* @return \OC\User\User
|
* @return \OC\User\User
|
||||||
*/
|
*/
|
||||||
protected function getUserObject($uid, $backend) {
|
protected function getUserObject($uid, $backend, $cacheUser = true) {
|
||||||
if (isset($this->cachedUsers[$uid])) {
|
if (isset($this->cachedUsers[$uid])) {
|
||||||
return $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;
|
$offset = 0;
|
||||||
do {
|
do {
|
||||||
$users = $backend->getUsers($search, $limit, $offset);
|
$users = $backend->getUsers($search, $limit, $offset);
|
||||||
foreach ($users as $user) {
|
foreach ($users as $uid) {
|
||||||
$user = $this->get($user);
|
if (!$backend->userExists($uid)) {
|
||||||
if (is_null($user)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$user = $this->getUserObject($uid, $backend, false);
|
||||||
$return = $callback($user);
|
$return = $callback($user);
|
||||||
if ($return === false) {
|
if ($return === false) {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue