cache group existence early to save useless requests to LDAP
we do it for users already Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
69ae7abe72
commit
79667b58a9
|
@ -656,6 +656,8 @@ class Access extends LDAPUtility {
|
|||
if ($this->ncUserManager instanceof PublicEmitter && $isUser) {
|
||||
$this->cacheUserExists($name);
|
||||
$this->ncUserManager->emit('\OC\User', 'assignedUserId', [$name]);
|
||||
} elseif (!$isUser) {
|
||||
$this->cacheGroupExists($name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -765,6 +767,13 @@ class Access extends LDAPUtility {
|
|||
$this->connection->writeToCache('userExists'.$ocName, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* caches a group as existing
|
||||
*/
|
||||
public function cacheGroupExists(string $gid): void {
|
||||
$this->connection->writeToCache('groupExists'.$gid, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* caches the user display name
|
||||
*
|
||||
|
@ -962,7 +971,15 @@ class Access extends LDAPUtility {
|
|||
* @return array
|
||||
*/
|
||||
public function fetchListOfGroups($filter, $attr, $limit = null, $offset = null) {
|
||||
return $this->fetchList($this->searchGroups($filter, $attr, $limit, $offset), $this->manyAttributes($attr));
|
||||
$groupRecords = $this->searchGroups($filter, $attr, $limit, $offset);
|
||||
array_walk($groupRecords, function($record) {
|
||||
$newlyMapped = false;
|
||||
$gid = $this->dn2ocname($record['dn'][0], null, false, $newlyMapped, $record);
|
||||
if(!$newlyMapped && is_string($gid)) {
|
||||
$this->cacheGroupExists($gid);
|
||||
}
|
||||
});
|
||||
return $this->fetchList($groupRecords, $this->manyAttributes($attr));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1148,7 +1148,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
|
|||
$uuid,
|
||||
false
|
||||
);
|
||||
$this->access->connection->writeToCache("groupExists" . $gid, true);
|
||||
$this->access->cacheGroupExists($gid);
|
||||
}
|
||||
}
|
||||
return $dn != null;
|
||||
|
|
Loading…
Reference in New Issue