Skip to content

Commit 9c10593

Browse files
committed
fix: prevent recursion in SharesUpdatedListener
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 3b70d0f commit 9c10593

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

apps/files_sharing/lib/Listener/SharesUpdatedListener.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
* @template-implements IEventListener<UserAddedEvent|UserRemovedEvent|ShareCreatedEvent|ShareTransferredEvent|BeforeShareDeletedEvent|UserShareAccessUpdatedEvent>
3030
*/
3131
class SharesUpdatedListener implements IEventListener {
32+
private array $inUpdate = [];
33+
3234
public function __construct(
3335
private readonly IManager $shareManager,
3436
private readonly IUserMountCache $userMountCache,
@@ -57,6 +59,12 @@ public function handle(Event $event): void {
5759
}
5860

5961
private function updateForUser(IUser $user): void {
62+
// prevent recursion
63+
if (isset($this->inUpdate[$user->getUID()])) {
64+
return;
65+
}
66+
$this->inUpdate[$user->getUID()] = true;
67+
6068
$cachedMounts = $this->userMountCache->getMountsForUser($user);
6169
$mountPoints = array_map(fn (ICachedMountInfo $mount) => $mount->getMountPoint(), $cachedMounts);
6270
$mountsByPath = array_combine($mountPoints, $cachedMounts);
@@ -71,5 +79,7 @@ private function updateForUser(IUser $user): void {
7179
$this->shareTargetValidator->verifyMountPoint($user, $parentShare, $mountsByPath, $groupedShares);
7280
}
7381
}
82+
83+
unset($this->inUpdate[$user->getUID()]);
7484
}
7585
}

0 commit comments

Comments
 (0)