Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions lib/private/User/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function createUser(string $uid, string $password): bool {
$result = $qb->execute();

// Clear cache
unset($this->cache[$uid]);
unset($this->cache[mb_strtolower($uid)]);

return $result ? true : false;
}
Expand All @@ -172,8 +172,8 @@ public function deleteUser($uid) {
->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;
Expand Down Expand Up @@ -232,7 +232,7 @@ public function setDisplayName(string $uid, string $displayName): bool {
->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;
}
Expand All @@ -249,7 +249,7 @@ public function setDisplayName(string $uid, string $displayName): bool {
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'];
}

/**
Expand Down Expand Up @@ -381,10 +381,10 @@ private function loadUser($uid) {
$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;
}

Expand All @@ -400,12 +400,12 @@ private function loadUser($uid) {
$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;
}
Expand Down Expand Up @@ -441,7 +441,7 @@ public function getUsers($search = '', $limit = null, $offset = null) {
*/
public function userExists($uid) {
$this->loadUser($uid);
return $this->cache[$uid] !== false;
return $this->cache[mb_strtolower($uid)] !== false;
}

/**
Expand Down Expand Up @@ -489,7 +489,7 @@ public function countUsers() {
*/
public function loginName2UserName($loginName) {
if ($this->userExists($loginName)) {
return $this->cache[$loginName]['uid'];
return $this->cache[mb_strtolower($loginName)]['uid'];
}

return false;
Expand Down Expand Up @@ -527,7 +527,7 @@ public function getRealUID(string $uid): string {
throw new \RuntimeException($uid . ' does not exist');
}

return $this->cache[$uid]['uid'];
return $this->cache[mb_strtolower($uid)]['uid'];
}

private function fixLimit($limit) {
Expand Down