From 3e8502d23995710dd44ea4bd912225ffc4d89156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 16 Oct 2025 16:53:20 +0200 Subject: [PATCH] fix(shares): Fix infinite loop when hide_disabled_user_shares is yes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/Share20/Manager.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 435464a67ab7f..93f3fa44b9dc1 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1265,16 +1265,16 @@ public function getSharesBy($userId, $shareType, $path = null, $reshares = false while (true) { $added = 0; foreach ($shares as $share) { + $added++; if ($onlyValid) { try { - $this->checkShare($share); + $this->checkShare($share, $added); } catch (ShareNotFound $e) { // Ignore since this basically means the share is deleted continue; } } - $added++; $shares2[] = $share; if (count($shares2) === $limit) { @@ -1480,11 +1480,14 @@ public function getShareByToken($token) { /** * Check expire date and disabled owner * + * @param int &$added If given, will be decremented if the share is deleted * @throws ShareNotFound */ - protected function checkShare(IShare $share): void { + private function checkShare(IShare $share, int &$added = 1): void { if ($share->isExpired()) { $this->deleteShare($share); + // Remove 1 to added, because this share was deleted + $added--; throw new ShareNotFound($this->l->t('The requested share does not exist anymore')); } if ($this->config->getAppValue('files_sharing', 'hide_disabled_user_shares', 'no') === 'yes') {