Skip to content
Snippets Groups Projects
Commit 2dcd97bf authored by Roeland Jago Douma's avatar Roeland Jago Douma Committed by GitHub
Browse files

Merge pull request #1672 from nextcloud/cache_non_exisiting_db_user

Cache non existing DB user
parents a0cb8093 1273d82e
No related branches found
No related tags found
No related merge requests found
......@@ -94,6 +94,9 @@ class Database extends Backend implements IUserBackend {
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*users` ( `uid`, `password` ) VALUES( ?, ? )');
$result = $query->execute(array($uid, \OC::$server->getHasher()->hash($password)));
// Clear cache
unset($this->cache[$uid]);
return $result ? true : false;
}
......@@ -234,7 +237,7 @@ class Database extends Backend implements IUserBackend {
* @return boolean
*/
private function loadUser($uid) {
if (empty($this->cache[$uid])) {
if (!isset($this->cache[$uid])) {
$query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)');
$result = $query->execute(array($uid));
......@@ -243,6 +246,8 @@ class Database extends Backend implements IUserBackend {
return false;
}
$this->cache[$uid] = false;
while ($row = $result->fetchRow()) {
$this->cache[$uid]['uid'] = $row['uid'];
$this->cache[$uid]['displayname'] = $row['displayname'];
......@@ -284,7 +289,7 @@ class Database extends Backend implements IUserBackend {
*/
public function userExists($uid) {
$this->loadUser($uid);
return !empty($this->cache[$uid]);
return $this->cache[$uid] !== false;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment