filter out oc_mounts results from non existing users
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
3bfc1404b8
commit
b884c25950
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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]);
|
||||
|
|
Loading…
Reference in New Issue