From dbb6b4cbb90c21a1256e62014849055b723a0f66 Mon Sep 17 00:00:00 2001 From: =?utf8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Mon, 19 Aug 2019 10:53:29 +0200 Subject: [PATCH] Filter out duplicated shares before processing them MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- .../lib/Controller/ShareAPIController.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 218d854f2f1..134ff6378e7 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -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; -- 2.39.5