]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(dav): Handle no next potential toggle in availability detection 37167/head
authorThomas Citharel <tcit@tcit.fr>
Fri, 10 Mar 2023 08:40:36 +0000 (09:40 +0100)
committerThomas Citharel <tcit@tcit.fr>
Fri, 10 Mar 2023 11:18:13 +0000 (12:18 +0100)
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 <tcit@tcit.fr>
apps/dav/lib/BackgroundJob/UserStatusAutomation.php

index 94feadcae935aa2e000e83c9b180ab4f4c8c721a..8edc28c9a69a7f14deda53c65ef3cdcfb5494f9e 100644 (file)
@@ -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);