$cacheKey = $this->getGroupCacheKey($gid);
foreach ($this->backends as $configPrefix => $backend) {
if ($result = call_user_func_array([$backend, $method], $parameters)) {
- $this->writeToCache($cacheKey, $configPrefix);
+ if(!$this->isSingleBackend()) {
+ $this->writeToCache($cacheKey, $configPrefix);
+ }
return $result;
}
}
return false;
}
+ protected function activeBackends(): int {
+ return count($this->backends);
+ }
+
/**
* is user in group?
* @param string $uid uid of the user
abstract class Proxy {
private static $accesses = [];
private $ldap = null;
+ /** @var bool */
+ private $isSingleBackend;
/** @var \OCP\ICache|null */
private $cache;
*/
abstract public function getLDAPAccess($id);
+ abstract protected function activeBackends(): int;
+
+ protected function isSingleBackend(): bool{
+ if($this->isSingleBackend === null) {
+ $this->isSingleBackend = $this->activeBackends() === 1;
+ }
+ return $this->isSingleBackend;
+ }
+
/**
* Takes care of the request to the User backend
* @param string $id
* @return mixed, the result of the specified method
*/
protected function handleRequest($id, $method, $parameters, $passOnWhen = false) {
- $result = $this->callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
- if ($result === $passOnWhen) {
+ if (!$this->isSingleBackend()) {
+ $result = $this->callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
+ }
+ if (!isset($result) || $result === $passOnWhen) {
$result = $this->walkBackends($id, $method, $parameters);
}
return $result;
$instance = $this->getAccess($configPrefix);
}
if ($result = call_user_func_array([$instance, $method], $parameters)) {
- $this->writeToCache($cacheKey, $configPrefix);
+ if(!$this->isSingleBackend()) {
+ $this->writeToCache($cacheKey, $configPrefix);
+ }
return $result;
}
}
return false;
}
+ protected function activeBackends(): int {
+ return count($this->backends);
+ }
+
/**
* Check if backend implements actions
* @param int $actions bitwise-or'ed actions