diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2023-06-08 23:32:16 +0200 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-06-23 23:04:40 +0000 |
commit | 3813b955eeacded0c991befe7d1f49cbfc33ef30 (patch) | |
tree | c03f7e50da66312aa36af382af15bcd20fbcec6d /lib/private/Files/Cache/QuerySearchHelper.php | |
parent | ae48fc86d229e9575f3ca49ad659cd73b31a0c36 (diff) | |
download | nextcloud-server-3813b955eeacded0c991befe7d1f49cbfc33ef30.tar.gz nextcloud-server-3813b955eeacded0c991befe7d1f49cbfc33ef30.zip |
chore: ugly type juggling
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Files/Cache/QuerySearchHelper.php')
-rw-r--r-- | lib/private/Files/Cache/QuerySearchHelper.php | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index 52663213b16..b4376eb2d98 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -195,23 +195,33 @@ class QuerySearchHelper { } /** - * @return array{array<string, ICache>, array<string, IMountPoint>} + * @return list{0?: array<array-key, ICache>, 1?: array<array-key, IMountPoint>} */ public function getCachesAndMountPointsForSearch(IRootFolder $root, string $path, bool $limitToHome = false): array { $rootLength = strlen($path); - $mount = $root->getMount($path); - $storage = $mount->getStorage(); + $storage = null; + if (method_exists($root, 'getMount')) { + /** @var IMountPoint $mount */ + $mount = $root->getMount($path); + $storage = $mount->getStorage(); + } + if ($storage === null) { + return []; + } $internalPath = $mount->getInternalPath($path); if ($internalPath !== '') { // a temporary CacheJail is used to handle filtering down the results to within this folder + /** @var ICache[] $caches */ $caches = ['' => new CacheJail($storage->getCache(''), $internalPath)]; } else { + /** @var ICache[] $caches */ $caches = ['' => $storage->getCache('')]; } + /** @var IMountPoint[] $mountByMountPoint */ $mountByMountPoint = ['' => $mount]; - if (!$limitToHome) { + if (!$limitToHome && method_exists($root, 'getMountsIn')) { /** @var IMountPoint[] $mounts */ $mounts = $root->getMountsIn($path); foreach ($mounts as $mount) { |