Skip to content

Commit

Permalink
Merge pull request #3007 from Loki3000/master
Browse files Browse the repository at this point in the history
Remove non required db requests
  • Loading branch information
rullzer authored Jan 11, 2017
2 parents c4e51fd + 7e06f05 commit 005ce8a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/private/AllConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,17 @@ public function deleteAppFromAllUsers($appName) {
* ]
*/
private function getUserValues($userId) {
// TODO - FIXME
$this->fixDIInit();

if (isset($this->userCache[$userId])) {
return $this->userCache[$userId];
}
if ($userId === null || $userId === '') {
$this->userCache[$userId]=array();
return $this->userCache[$userId];
}

// TODO - FIXME
$this->fixDIInit();

$data = array();
$query = 'SELECT `appid`, `configkey`, `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ?';
$result = $this->connection->executeQuery($query, array($userId));
Expand Down
5 changes: 5 additions & 0 deletions lib/private/Group/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ public function removeFromGroup( $uid, $gid ) {
* if the user exists at all.
*/
public function getUserGroups( $uid ) {
//guests has empty or null $uid
if ($uid === null || $uid === '') {
return [];
}

$this->fixDI();

// No magic!
Expand Down
7 changes: 6 additions & 1 deletion lib/private/User/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class Database extends Backend implements IUserBackend {
*/
public function __construct($eventDispatcher = null) {
$this->cache = new CappedMemoryCache();
$this->cache[null] = false;
$this->eventDispatcher = $eventDispatcher ? $eventDispatcher : \OC::$server->getEventDispatcher();
}

Expand Down Expand Up @@ -239,6 +238,12 @@ public function checkPassword($uid, $password) {
*/
private function loadUser($uid) {
if (!isset($this->cache[$uid])) {
//guests $uid could be NULL or ''
if ($uid === null || $uid === '') {
$this->cache[$uid]=false;
return true;
}

$query = \OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)');
$result = $query->execute(array($uid));

Expand Down

0 comments on commit 005ce8a

Please sign in to comment.