Make the database user backend cache case insensitive like the DB table
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
1e77bf8d78
commit
586052aba6
|
@ -142,7 +142,7 @@ class Database extends ABackend
|
|||
$result = $qb->execute();
|
||||
|
||||
// Clear cache
|
||||
unset($this->cache[$uid]);
|
||||
unset($this->cache[mb_strtolower($uid)]);
|
||||
|
||||
return $result ? true : false;
|
||||
}
|
||||
|
@ -167,8 +167,8 @@ class Database extends ABackend
|
|||
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
|
||||
$result = $query->execute();
|
||||
|
||||
if (isset($this->cache[$uid])) {
|
||||
unset($this->cache[$uid]);
|
||||
if (isset($this->cache[mb_strtolower($uid)])) {
|
||||
unset($this->cache[mb_strtolower($uid)]);
|
||||
}
|
||||
|
||||
return $result ? true : false;
|
||||
|
@ -228,7 +228,7 @@ class Database extends ABackend
|
|||
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
|
||||
$query->execute();
|
||||
|
||||
$this->cache[$uid]['displayname'] = $displayName;
|
||||
$this->cache[mb_strtolower($uid)]['displayname'] = $displayName;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ class Database extends ABackend
|
|||
public function getDisplayName($uid): string {
|
||||
$uid = (string)$uid;
|
||||
$this->loadUser($uid);
|
||||
return empty($this->cache[$uid]['displayname']) ? $uid : $this->cache[$uid]['displayname'];
|
||||
return empty($this->cache[mb_strtolower($uid)]['displayname']) ? $uid : $this->cache[mb_strtolower($uid)]['displayname'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -336,10 +336,10 @@ class Database extends ABackend
|
|||
$this->fixDI();
|
||||
|
||||
$uid = (string)$uid;
|
||||
if (!isset($this->cache[$uid])) {
|
||||
if (!isset($this->cache[mb_strtolower($uid)])) {
|
||||
//guests $uid could be NULL or ''
|
||||
if ($uid === '') {
|
||||
$this->cache[$uid] = false;
|
||||
$this->cache[mb_strtolower($uid)] = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -355,12 +355,12 @@ class Database extends ABackend
|
|||
$row = $result->fetch();
|
||||
$result->closeCursor();
|
||||
|
||||
$this->cache[$uid] = false;
|
||||
$this->cache[mb_strtolower($uid)] = false;
|
||||
|
||||
// "uid" is primary key, so there can only be a single result
|
||||
if ($row !== false) {
|
||||
$this->cache[$uid]['uid'] = (string)$row['uid'];
|
||||
$this->cache[$uid]['displayname'] = (string)$row['displayname'];
|
||||
$this->cache[mb_strtolower($uid)]['uid'] = (string)$row['uid'];
|
||||
$this->cache[mb_strtolower($uid)]['displayname'] = (string)$row['displayname'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ class Database extends ABackend
|
|||
*/
|
||||
public function userExists($uid) {
|
||||
$this->loadUser($uid);
|
||||
return $this->cache[$uid] !== false;
|
||||
return $this->cache[mb_strtolower($uid)] !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -442,7 +442,7 @@ class Database extends ABackend
|
|||
*/
|
||||
public function loginName2UserName($loginName) {
|
||||
if ($this->userExists($loginName)) {
|
||||
return $this->cache[$loginName]['uid'];
|
||||
return $this->cache[mb_strtolower($loginName)]['uid'];
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue