[BUGFIX] Exception when scheduling "at" execution time 06/18106/4
authorAndreas Wolf <andreas.wolf@typo3.org>
Sun, 10 Feb 2013 00:00:25 +0000 (01:00 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 10 Feb 2013 00:29:00 +0000 (01:29 +0100)
If a recurring task is converted to a single task and the endtime is set
before now, then the exception "Task is past end date" is thrown as the
next execution time for the "at" daemon is calculated.

The fix is to catch the exceptions and ignore them, as we don't care
about tasks that will never run again when calculating the next
execution date.

Fixes: #45265
Releases: 6.1, 6.0
Change-Id: If6fd368e6c11c0b9058eb8a82a736220ef538b70
Reviewed-on: https://review.typo3.org/18106
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/scheduler/Classes/Execution.php
typo3/sysext/scheduler/Classes/Scheduler.php

index 5ebd448..5493883 100644 (file)
@@ -207,6 +207,7 @@ class Execution {
         * This method gets or calculates the next execution date
         *
         * @return integer Timestamp of the next execution
+        * @throws \OutOfBoundsException
         */
        public function getNextExecution() {
                if ($this->getIsNewSingleExecution()) {
index 5a52869..220eb21 100644 (file)
@@ -401,10 +401,15 @@ class Scheduler implements \TYPO3\CMS\Core\SingletonInterface {
                $tasks = $this->fetchTasksWithCondition('');
                $nextExecution = FALSE;
                foreach ($tasks as $task) {
-                       /** @var $task \TYPO3\CMS\Scheduler\Task\AbstractTask */
-                       $tempNextExecution = $task->getNextDueExecution();
-                       if ($nextExecution === FALSE || $tempNextExecution < $nextExecution) {
-                               $nextExecution = $tempNextExecution;
+                       try {
+                               /** @var $task \TYPO3\CMS\Scheduler\Task\AbstractTask */
+                               $tempNextExecution = $task->getNextDueExecution();
+                               if ($nextExecution === FALSE || $tempNextExecution < $nextExecution) {
+                                       $nextExecution = $tempNextExecution;
+                               }
+                       } catch (\OutOfBoundsException $e) {
+                               // The event will not be executed again or has already ended - we don't have to consider it for
+                               // scheduling the next "at" run
                        }
                }
                if ($nextExecution !== FALSE) {