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();
|
$result = $qb->execute();
|
||||||
|
|
||||||
// Clear cache
|
// Clear cache
|
||||||
unset($this->cache[$uid]);
|
unset($this->cache[mb_strtolower($uid)]);
|
||||||
|
|
||||||
return $result ? true : false;
|
return $result ? true : false;
|
||||||
}
|
}
|
||||||
|
@ -167,8 +167,8 @@ class Database extends ABackend
|
||||||
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
|
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
|
||||||
$result = $query->execute();
|
$result = $query->execute();
|
||||||
|
|
||||||
if (isset($this->cache[$uid])) {
|
if (isset($this->cache[mb_strtolower($uid)])) {
|
||||||
unset($this->cache[$uid]);
|
unset($this->cache[mb_strtolower($uid)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result ? true : false;
|
return $result ? true : false;
|
||||||
|
@ -228,7 +228,7 @@ class Database extends ABackend
|
||||||
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
|
->where($query->expr()->eq('uid_lower', $query->createNamedParameter(mb_strtolower($uid))));
|
||||||
$query->execute();
|
$query->execute();
|
||||||
|
|
||||||
$this->cache[$uid]['displayname'] = $displayName;
|
$this->cache[mb_strtolower($uid)]['displayname'] = $displayName;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ class Database extends ABackend
|
||||||
public function getDisplayName($uid): string {
|
public function getDisplayName($uid): string {
|
||||||
$uid = (string)$uid;
|
$uid = (string)$uid;
|
||||||
$this->loadUser($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();
|
$this->fixDI();
|
||||||
|
|
||||||
$uid = (string)$uid;
|
$uid = (string)$uid;
|
||||||
if (!isset($this->cache[$uid])) {
|
if (!isset($this->cache[mb_strtolower($uid)])) {
|
||||||
//guests $uid could be NULL or ''
|
//guests $uid could be NULL or ''
|
||||||
if ($uid === '') {
|
if ($uid === '') {
|
||||||
$this->cache[$uid] = false;
|
$this->cache[mb_strtolower($uid)] = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,12 +355,12 @@ class Database extends ABackend
|
||||||
$row = $result->fetch();
|
$row = $result->fetch();
|
||||||
$result->closeCursor();
|
$result->closeCursor();
|
||||||
|
|
||||||
$this->cache[$uid] = false;
|
$this->cache[mb_strtolower($uid)] = false;
|
||||||
|
|
||||||
// "uid" is primary key, so there can only be a single result
|
// "uid" is primary key, so there can only be a single result
|
||||||
if ($row !== false) {
|
if ($row !== false) {
|
||||||
$this->cache[$uid]['uid'] = (string)$row['uid'];
|
$this->cache[mb_strtolower($uid)]['uid'] = (string)$row['uid'];
|
||||||
$this->cache[$uid]['displayname'] = (string)$row['displayname'];
|
$this->cache[mb_strtolower($uid)]['displayname'] = (string)$row['displayname'];
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,7 @@ class Database extends ABackend
|
||||||
*/
|
*/
|
||||||
public function userExists($uid) {
|
public function userExists($uid) {
|
||||||
$this->loadUser($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) {
|
public function loginName2UserName($loginName) {
|
||||||
if ($this->userExists($loginName)) {
|
if ($this->userExists($loginName)) {
|
||||||
return $this->cache[$loginName]['uid'];
|
return $this->cache[mb_strtolower($loginName)]['uid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue