diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index bd8343fa440..6feb3085e9e 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -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)); } /** diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php index 8e569c50e09..0fd9213e9a0 100644 --- a/tests/lib/Files/Config/UserMountCacheTest.php +++ b/tests/lib/Files/Config/UserMountCacheTest.php @@ -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]);