Skip to content
Merged
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
9 changes: 7 additions & 2 deletions lib/private/User/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public function createUser($uid, $password) {
$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;
}

Expand Down Expand Up @@ -234,7 +237,7 @@ public function checkPassword($uid, $password) {
* @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));

Expand All @@ -243,6 +246,8 @@ private function loadUser($uid) {
return false;
}

$this->cache[$uid] = false;

while ($row = $result->fetchRow()) {
$this->cache[$uid]['uid'] = $row['uid'];
$this->cache[$uid]['displayname'] = $row['displayname'];
Expand Down Expand Up @@ -284,7 +289,7 @@ public function getUsers($search = '', $limit = null, $offset = null) {
*/
public function userExists($uid) {
$this->loadUser($uid);
return !empty($this->cache[$uid]);
return $this->cache[$uid] !== false;
}

/**
Expand Down