summaryrefslogtreecommitdiffstats
path: root/lib/private/User
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2017-02-15 18:14:29 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-03-20 02:03:03 -0600
commitaacfef463c07f6a1cacfd4b2c014ba582f4811de (patch)
treea7350be5ff3e8a79b68d2d1990c3e205233d5f8a /lib/private/User
parent592c04a9db83c27df8155ae97c6693fe2170e543 (diff)
downloadnextcloud-server-aacfef463c07f6a1cacfd4b2c014ba582f4811de.tar.gz
nextcloud-server-aacfef463c07f6a1cacfd4b2c014ba582f4811de.zip
Add tests for database user backend caching
Add comment, closeCursor in user DB query Invalidate user in cache after successful creation Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/private/User')
-rw-r--r--lib/private/User/Database.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php
index efa6672ccee..ec463ba91dd 100644
--- a/lib/private/User/Database.php
+++ b/lib/private/User/Database.php
@@ -234,7 +234,7 @@ class Database extends Backend implements IUserBackend {
/**
* Load an user in the cache
* @param string $uid the username
- * @return boolean
+ * @return boolean true if user was found, false otherwise
*/
private function loadUser($uid) {
if (!isset($this->cache[$uid])) {
@@ -254,9 +254,14 @@ class Database extends Backend implements IUserBackend {
$this->cache[$uid] = false;
+ // "uid" is primary key, so there can only be a single result
if ($row = $result->fetchRow()) {
$this->cache[$uid]['uid'] = $row['uid'];
$this->cache[$uid]['displayname'] = $row['displayname'];
+ $result->closeCursor();
+ } else {
+ $result->closeCursor();
+ return false;
}
}