From 3fa79ac7b30a14bf6eae536dbd059d34f25ec64d Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Tue, 28 Apr 2026 15:18:06 +0200 Subject: [PATCH] fix(TaskProcessingWorkerIsRunning): Different message if the worker has never run Signed-off-by: Marcel Klehr --- .../lib/SetupChecks/TaskProcessingWorkerIsRunning.php | 11 +++++++++-- .../SetupChecks/TaskProcessingWorkerIsRunningTest.php | 6 +++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/settings/lib/SetupChecks/TaskProcessingWorkerIsRunning.php b/apps/settings/lib/SetupChecks/TaskProcessingWorkerIsRunning.php index ad977e1c2ec..c3ab5c88450 100644 --- a/apps/settings/lib/SetupChecks/TaskProcessingWorkerIsRunning.php +++ b/apps/settings/lib/SetupChecks/TaskProcessingWorkerIsRunning.php @@ -54,11 +54,18 @@ class TaskProcessingWorkerIsRunning implements ISetupCheck { $lastIteration = (int)$this->appConfig->getValueString('core', 'taskprocessing_worker_last_iteration', lazy: true); if ($lastIteration > $this->timeFactory->now()->getTimestamp() - (60 * self::IS_RUNNING_IN_LAST_X_MINUTES)) { return SetupResult::success( - $this->l10n->n('The Task Processing worker has run in the last minute.', 'The Task Processing worker has run in the last %n minute.', self::IS_RUNNING_IN_LAST_X_MINUTES) + $this->l10n->n('The Task Processing worker has run in the last minute.', 'The Task Processing worker has run in the last %n minutes.', self::IS_RUNNING_IN_LAST_X_MINUTES) ); } + + if ($lastIteration > 0) { + return SetupResult::warning( + $this->l10n->t('The Task Processing worker does not seem to be running. The last run was at %s.', [date('Y-m-d H:i:s', $lastIteration)]) + ); + } + return SetupResult::warning( - $this->l10n->t('The Task Processing worker does not seem to be running. The last run was at %s.', [date('Y-m-d H:i:s', (int)$this->appConfig->getValueString('core', 'taskprocessing_worker_last_iteration'))]) + $this->l10n->t('The Task Processing worker does not seem to be running. It seems it has never run so far.') ); } } diff --git a/apps/settings/tests/SetupChecks/TaskProcessingWorkerIsRunningTest.php b/apps/settings/tests/SetupChecks/TaskProcessingWorkerIsRunningTest.php index 61b9dd95932..43df9e599b6 100644 --- a/apps/settings/tests/SetupChecks/TaskProcessingWorkerIsRunningTest.php +++ b/apps/settings/tests/SetupChecks/TaskProcessingWorkerIsRunningTest.php @@ -3,7 +3,7 @@ declare(strict_types=1); /** - * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\Settings\Tests; @@ -53,7 +53,7 @@ class TaskProcessingWorkerIsRunningTest extends TestCase { $tasks[] = $task; } $this->taskProcessingManager->method('getTasks')->willReturn($tasks); - + $this->timeFactory->method('now')->willReturn(new \DateTimeImmutable()); $this->appConfig->method('getValueString')->willReturn((string)$this->timeFactory->now()->getTimestamp()); $this->assertEquals(SetupResult::SUCCESS, $this->check->run()->getSeverity()); @@ -70,7 +70,7 @@ class TaskProcessingWorkerIsRunningTest extends TestCase { $tasks[] = $task; } $this->taskProcessingManager->method('getTasks')->willReturn($tasks); - + $this->timeFactory->method('now')->willReturn(new \DateTimeImmutable()); $this->appConfig->method('getValueString')->willReturn((string)($this->timeFactory->now()->getTimestamp() - 60 * 10)); $this->assertEquals(SetupResult::WARNING, $this->check->run()->getSeverity());