Skip to content

Commit 310945d

Browse files
committed
feat: Catch callback exception in callForSeenUsers
In case of large instances, `callForSeenUsers()` can take a lot of time to finish. The new arguments give the opportunity for the caller to set a time limit, and to start from a given offset. The method now also returns the offset if it was stopped early. Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent 50e8c66 commit 310945d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/private/User/Manager.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,13 @@ public function callForSeenUsers(\Closure $callback, int|null $maxTime, int $off
637637
foreach ($this->backends as $backend) {
638638
if ($backend->userExists($userId)) {
639639
$user = $this->getUserObject($userId, $backend, false);
640-
$return = $callback($user);
641-
if ($return === false) {
642-
return 0;
640+
try {
641+
$return = $callback($user);
642+
if ($return === false) {
643+
return 0;
644+
}
645+
} catch (\Throwable $e) {
646+
$this->logger->error('Error while calling callback for seen users', ['exception' => $e, 'userId' => $userId, 'backend' => $backend::class]);
643647
}
644648
break;
645649
}

0 commit comments

Comments
 (0)