]> source.dussan.org Git - nextcloud-server.git/commitdiff
Filter out duplicated shares before processing them
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Mon, 19 Aug 2019 08:53:29 +0000 (10:53 +0200)
committerDaniel Calviño Sánchez <danxuliu@gmail.com>
Fri, 25 Oct 2019 19:41:12 +0000 (21:41 +0200)
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
apps/files_sharing/lib/Controller/ShareAPIController.php

index 218d854f2f16d5f1d2cc32e9c17ed022be19f42d..134ff6378e79ccb0e64c2fd466d7f0b137d8f396 100644 (file)
@@ -628,18 +628,26 @@ class ShareAPIController extends OCSController {
                        return $carry;
                }, []);
 
+               // filter out duplicate shares
+               $known = [];
+               $shares = array_filter($shares, function($share) use (&$known) {
+                       if (in_array($share->getId(), $known)) {
+                               return false;
+                       }
+                       $known[] = $share->getId();
+                       return true;
+               });
+
                $formatted = $miniFormatted = [];
                $resharingRight = false;
-               $known = [];
                foreach ($shares as $share) {
-                       if (in_array($share->getId(), $known) || $share->getSharedWith() === $this->currentUser) {
+                       if ($share->getSharedWith() === $this->currentUser) {
                                continue;
                        }
 
                        try {
                                $format = $this->formatShare($share);
 
-                               $known[] = $share->getId();
                                $formatted[] = $format;
                                if ($share->getSharedBy() === $this->currentUser) {
                                        $miniFormatted[] = $format;