diff options
author | nfebe <fenn25.fn@gmail.com> | 2025-03-07 17:18:00 +0100 |
---|---|---|
committer | F. E Noel Nfebe <fenn25.fn@gmail.com> | 2025-04-25 01:13:01 +0200 |
commit | 6aaba03c402a8917d88e78ccb8af65d973a4428b (patch) | |
tree | 60fcf453484debf3ddcaf251ffe8abb3bef470b1 | |
parent | d3e2a0b4f2357bd8d3dbf3f79200b699dbc53813 (diff) | |
download | nextcloud-server-fix/51226/show-remote-shares-as-external.tar.gz nextcloud-server-fix/51226/show-remote-shares-as-external.zip |
feat: Only getShares for provided typesfix/51226/show-remote-shares-as-external
With the types filter in place (1e7f53e9bb791c151b5aa637974f6689386ebd33) we should avoid,
fetching all shares.
Preventing potential N+1s
Signed-off-by: nfebe <fenn25.fn@gmail.com>
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareAPIController.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index f77633621b3..d277e8031c7 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -1077,7 +1077,7 @@ class ShareAPIController extends OCSController { return $this->getSharesInDir($node); } - $shares = $this->getSharesFromNode($viewer, $node, $reShares); + $shares = $this->getSharesFromNode($viewer, $node, $reShares, $types); $known = $formatted = $miniFormatted = []; $resharingRight = false; @@ -1887,7 +1887,7 @@ class ShareAPIController extends OCSController { * * @return IShare[] */ - private function getSharesFromNode(string $viewer, $node, bool $reShares): array { + private function getSharesFromNode(string $viewer, $node, bool $reShares, array $limitToProviders = []): array { $providers = [ IShare::TYPE_USER, IShare::TYPE_GROUP, @@ -1899,6 +1899,10 @@ class ShareAPIController extends OCSController { IShare::TYPE_SCIENCEMESH ]; + if (count($limitToProviders) > 0) { + $providers = $limitToProviders; + } + // Should we assume that the (currentUser) viewer is the owner of the node !? $shares = []; foreach ($providers as $provider) { |