Skip to content

Commit 1a50c7e

Browse files
come-ncbackportbot[bot]
authored andcommitted
fix(shares): Fix infinite loop when hide_disabled_user_shares is yes
Signed-off-by: Côme Chilliet <[email protected]>
1 parent ba8514c commit 1a50c7e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/private/Share20/Manager.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,16 +1265,16 @@ public function getSharesBy($userId, $shareType, $path = null, $reshares = false
12651265
while (true) {
12661266
$added = 0;
12671267
foreach ($shares as $share) {
1268+
$added++;
12681269
if ($onlyValid) {
12691270
try {
1270-
$this->checkShare($share);
1271+
$this->checkShare($share, $added);
12711272
} catch (ShareNotFound $e) {
12721273
// Ignore since this basically means the share is deleted
12731274
continue;
12741275
}
12751276
}
12761277

1277-
$added++;
12781278
$shares2[] = $share;
12791279

12801280
if (count($shares2) === $limit) {
@@ -1480,11 +1480,14 @@ public function getShareByToken($token) {
14801480
/**
14811481
* Check expire date and disabled owner
14821482
*
1483+
* @param int &$added If given, will be decremented if the share is deleted
14831484
* @throws ShareNotFound
14841485
*/
1485-
protected function checkShare(IShare $share): void {
1486+
private function checkShare(IShare $share, int &$added = 1): void {
14861487
if ($share->isExpired()) {
14871488
$this->deleteShare($share);
1489+
// Remove 1 to added, because this share was deleted
1490+
$added--;
14881491
throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
14891492
}
14901493
if ($this->config->getAppValue('files_sharing', 'hide_disabled_user_shares', 'no') === 'yes') {

0 commit comments

Comments
 (0)