fix: add some extra checks for getMountsForPath arguments

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2026-01-15 11:16:29 +01:00
parent 83ac1c6030
commit 53b160ce9b
2 changed files with 12 additions and 7 deletions

View file

@ -84,9 +84,12 @@ class MountProviderCollection implements IMountProviderCollection, Emitter {
}
/**
* @param MountProviderArgs[] $mountProviderArgs
* @return array<string, IMountPoint> IMountPoint array indexed by mount
* point.
* The caller is responsible to ensure that all provided MountProviderArgs
* are for the same user.
* And that the `$providerClass` implements IPartialMountProvider.
*
* @param list<MountProviderArgs> $mountProviderArgs
* @return array<string, IMountPoint> IMountPoint array indexed by mount point.
*/
public function getUserMountsFromProviderByPath(
string $providerClass,
@ -98,14 +101,16 @@ class MountProviderCollection implements IMountProviderCollection, Emitter {
if ($provider === null) {
return [];
}
if (count($mountProviderArgs) === 0) {
return [];
}
if (!is_a($providerClass, IPartialMountProvider::class, true)) {
if (!$provider instanceof IPartialMountProvider) {
throw new \LogicException(
'Mount provider does not support partial mounts'
);
}
/** @var IPartialMountProvider $provider */
return $provider->getMountsForPath(
$path,
$forChildren,

View file

@ -600,7 +600,7 @@ class SetupManager {
}
$this->setupMountProviderPaths[$mountPoint] = self::SETUP_WITH_CHILDREN;
foreach ($authoritativeCachedMounts as $providerClass => $cachedMounts) {
$providerArgs = array_filter(array_map(
$providerArgs = array_values(array_filter(array_map(
static function (ICachedMountInfo $info) use ($rootsMetadata) {
$rootMetadata = $rootsMetadata[$info->getRootId()] ?? null;
@ -609,7 +609,7 @@ class SetupManager {
: null;
},
$cachedMounts
));
)));
$authoritativeMounts[] = $this->mountProviderCollection->getUserMountsFromProviderByPath(
$providerClass,
$path,