diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-02-24 22:03:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-24 22:03:53 +0300 |
commit | aaf1cb70a25896da3dd7ab1d9d1125f8ca62be66 (patch) | |
tree | 57ed52d3e3d420b74d825c15e221eceab6f5fc4e /apps/user_ldap | |
parent | b6a9cf21a302dd9e07e72ff12e927ff98b12f893 (diff) | |
parent | 407b8fddfc5db1da207f177bd2c7f5a06f13dfbd (diff) |
Merge pull request #19549 from nextcloud/fix/19418/uuid-attr-log-flood
remove noise from detectUuid and cache results
Diffstat (limited to 'apps/user_ldap')
-rw-r--r-- | apps/user_ldap/lib/Access.php | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php index 258222a7f3a..de02cbdf869 100644 --- a/apps/user_ldap/lib/Access.php +++ b/apps/user_ldap/lib/Access.php @@ -1712,13 +1712,19 @@ class Access extends LDAPUtility { $uuidOverride = $this->connection->ldapExpertUUIDGroupAttr; } - if(($this->connection->$uuidAttr !== 'auto') && !$force) { - return true; - } + if(!$force) { + if($this->connection->$uuidAttr !== 'auto') { + return true; + } else if (is_string($uuidOverride) && trim($uuidOverride) !== '') { + $this->connection->$uuidAttr = $uuidOverride; + return true; + } - if (is_string($uuidOverride) && trim($uuidOverride) !== '' && !$force) { - $this->connection->$uuidAttr = $uuidOverride; - return true; + $attribute = $this->connection->getFromCache($uuidAttr); + if(!$attribute === null) { + $this->connection->$uuidAttr = $attribute; + return true; + } } foreach(self::UUID_ATTRIBUTES as $attribute) { @@ -1727,27 +1733,29 @@ class Access extends LDAPUtility { if(isset($ldapRecord[$attribute])) { $this->connection->$uuidAttr = $attribute; return true; - } else { - continue; } + continue; } $value = $this->readAttribute($dn, $attribute); if(is_array($value) && isset($value[0]) && !empty($value[0])) { - \OCP\Util::writeLog( - 'user_ldap', - 'Setting '.$attribute.' as '.$uuidAttr, - ILogger::DEBUG + \OC::$server->getLogger()->debug( + 'Setting {attribute} as {subject}', + [ + 'app' => 'user_ldap', + 'attribute' => $attribute, + 'subject' => $uuidAttr + ] ); $this->connection->$uuidAttr = $attribute; + $this->connection->writeToCache($uuidAttr, $attribute); return true; + } elseif ($value === false) { + // record not available + return false; } } - \OCP\Util::writeLog( - 'user_ldap', - 'Could not autodetect the UUID attribute', - ILogger::ERROR - ); + \OC::$server->getLogger()->debug('Could not autodetect the UUID attribute', ['app' => 'user_ldap']); return false; } |