filter out oc_mounts results from non existing users

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2016-11-24 11:44:18 +01:00 committed by Joas Schilling
parent 3bfc1404b8
commit b884c25950
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
2 changed files with 7 additions and 4 deletions

View File

@ -187,6 +187,9 @@ class UserMountCache implements IUserMountCache {
private function dbRowToMountInfo(array $row) {
$user = $this->userManager->get($row['user_id']);
if (is_null($user)) {
return null;
}
return new CachedMountInfo($user, (int)$row['storage_id'], (int)$row['root_id'], $row['mount_point'], $row['mount_id']);
}
@ -203,7 +206,7 @@ class UserMountCache implements IUserMountCache {
$rows = $query->execute()->fetchAll();
$this->mountsForUsers[$user->getUID()] = array_map([$this, 'dbRowToMountInfo'], $rows);
$this->mountsForUsers[$user->getUID()] = array_filter(array_map([$this, 'dbRowToMountInfo'], $rows));
}
return $this->mountsForUsers[$user->getUID()];
}
@ -220,7 +223,7 @@ class UserMountCache implements IUserMountCache {
$rows = $query->execute()->fetchAll();
return array_map([$this, 'dbRowToMountInfo'], $rows);
return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows));
}
/**
@ -235,7 +238,7 @@ class UserMountCache implements IUserMountCache {
$rows = $query->execute()->fetchAll();
return array_map([$this, 'dbRowToMountInfo'], $rows);
return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows));
}
/**

View File

@ -410,7 +410,7 @@ class UserMountCacheTest extends TestCase {
public function testGetMountsForFileIdDeletedUser() {
$user1 = $this->userManager->get('u1');
list($storage1, $rootId) = $this->getStorage(2);
$storage1 = $this->getStorage(1, 2);
$rootId = $this->createCacheEntry('', 2);
$mount1 = new MountPoint($storage1, '/foo/');
$this->cache->registerMounts($user1, [$mount1]);