From: Thomas Citharel Date: Fri, 10 Mar 2023 08:40:36 +0000 (+0100) Subject: fix(dav): Handle no next potential toggle in availability detection X-Git-Tag: v27.0.0beta1~348^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5c5de0bac1bf1bc00c01707f1170446c6d895129;p=nextcloud-server.git fix(dav): Handle no next potential toggle in availability detection Fixes: min(): Array must contain at least one element at /var/www/nc/nextcloud/apps/dav/lib/BackgroundJob/UserStatusAutomation.php#142 Signed-off-by: Thomas Citharel --- diff --git a/apps/dav/lib/BackgroundJob/UserStatusAutomation.php b/apps/dav/lib/BackgroundJob/UserStatusAutomation.php index 94feadcae93..8edc28c9a69 100644 --- a/apps/dav/lib/BackgroundJob/UserStatusAutomation.php +++ b/apps/dav/lib/BackgroundJob/UserStatusAutomation.php @@ -139,6 +139,13 @@ class UserStatusAutomation extends TimedJob { } } + if (empty($nextPotentialToggles)) { + $this->logger->info('Removing ' . self::class . ' background job for user "' . $userId . '" because the user has no valid availability rules set'); + $this->jobList->remove(self::class, $argument); + $this->manager->revertUserStatus($userId, IUserStatus::MESSAGE_AVAILABILITY, IUserStatus::DND); + return; + } + $nextAutomaticToggle = min($nextPotentialToggles); $this->setLastRunToNextToggleTime($userId, $nextAutomaticToggle - 1);