From 868c88786bc9de49e8aac1555244249bba876939 Mon Sep 17 00:00:00 2001
From: Georg Ringer <georg.ringer@gmail.com>
Date: Thu, 24 Nov 2022 13:37:06 +0100
Subject: [PATCH] [BUGFIX] Allow empty end date for scheduler task
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

An empty end date of a scheduler task is valid and must be allowed.

Resolves: #99175
Resolves: #99878
Releases: main
Change-Id: I7dd1fd515a400e83c7eb71894c973817d0bb6261
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76805
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Josef Glatz <typo3@josefglatz.at>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Josef Glatz <typo3@josefglatz.at>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
---
 .../Classes/Controller/SchedulerModuleController.php          | 4 ++--
 .../Resources/Private/Partials/AddEditStartEndFields.html     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php b/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
index e026ac0ca4b2..2ce86d042392 100644
--- a/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
+++ b/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
@@ -403,7 +403,7 @@ class SchedulerModuleController
             'task_group' => (int)($parsedBody['task_group'] ?? 0),
             'type' => (int)($parsedBody['type'] ?? AbstractTask::TYPE_RECURRING),
             'start' => $parsedBody['start'] ?? $this->context->getAspect('date')->get('timestamp'),
-            'end' => $parsedBody['start'] ?? 0,
+            'end' => $parsedBody['end'] ?? 0,
             'frequency' => $parsedBody['frequency'] ?? '',
             'multiple' => (bool)($parsedBody['multiple'] ?? false),
             'description' => $parsedBody['description'] ?? '',
@@ -794,7 +794,7 @@ class SchedulerModuleController
                 $this->addMessage($view, $languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidStartDate'), ContextualFeedbackSeverity::ERROR);
             }
         }
-        if ($type === AbstractTask::TYPE_RECURRING && $endTime < $startTime) {
+        if ($type === AbstractTask::TYPE_RECURRING && $endTime > 0 && $endTime < $startTime) {
             $result = false;
             $this->addMessage($view, $languageService->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.endDateSmallerThanStartDate'), ContextualFeedbackSeverity::ERROR);
         }
diff --git a/typo3/sysext/scheduler/Resources/Private/Partials/AddEditStartEndFields.html b/typo3/sysext/scheduler/Resources/Private/Partials/AddEditStartEndFields.html
index 762a0128f846..6a1004fae300 100644
--- a/typo3/sysext/scheduler/Resources/Private/Partials/AddEditStartEndFields.html
+++ b/typo3/sysext/scheduler/Resources/Private/Partials/AddEditStartEndFields.html
@@ -24,7 +24,7 @@
             <label for="tceforms-datetimefield-task_end_row"><f:translate key="LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.end"/></label>
             <div class="form-control-wrap">
                 <div class="input-group" id="tceforms-datetimefield-task_end_row-wrapper">
-                    <f:variable name="formattedEnd"><f:if condition="{currentData.end} != 0"><f:then>{f:format.date(format:'H:i d-m-Y', date:currentData.end)}</f:then><f:else></f:else></f:if></f:variable>
+                    <f:variable name="formattedEnd"><f:if condition="{currentData.end}"><f:then>{f:format.date(format:'H:i d-m-Y', date:currentData.end)}</f:then><f:else></f:else></f:if></f:variable>
                     <input
                         name="tx_scheduler[end]_hr"
                         value="{formattedEnd}"
-- 
GitLab