[BUGFIX] Use proper exception messages for Scheduler::fetchTask() 85/59385/6
authorStefanos Karasavvidis <sk@karasavvidis.gr>
Wed, 9 Jan 2019 13:16:51 +0000 (15:16 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 1 Feb 2019 16:44:57 +0000 (17:44 +0100)
Use a proper message in case a non existent uid was passed and
correctly handle the case where no task uid was passed and no task
is overdue.

Resolves: #87375
Releases: master, 9.5, 8.7
Change-Id: I69d2798cc185451c889bf37d8a007eacf572c163
Reviewed-on: https://review.typo3.org/59385
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Fabien Udriot <fabien.udriot@ecodev.ch>
Tested-by: Fabien Udriot <fabien.udriot@ecodev.ch>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/scheduler/Classes/Scheduler.php

index 460ad08..e36a0f6 100644 (file)
@@ -334,12 +334,13 @@ class Scheduler implements SingletonInterface, LoggerAwareInterface
         }
 
         $row = $queryBuilder->execute()->fetch();
-        if ($row === false) {
-            throw new \OutOfBoundsException('Query could not be executed. Possible defect in tables tx_scheduler_task or tx_scheduler_task_group or DB server problems', 1422044826);
-        }
         if (empty($row)) {
-            // If there are no available tasks, thrown an exception
-            throw new \OutOfBoundsException('No task', 1247827244);
+            if (empty($uid)) {
+                // No uid was passed and no overdue task was found
+                throw new \OutOfBoundsException('No tasks available for execution', 1247827244);
+            }
+            // Although a uid was passed, no task with given was found
+            throw new \OutOfBoundsException('No task with id ' . $uid . ' found', 1422044826);
         }
         /** @var Task\AbstractTask $task */
         $task = unserialize($row['serialized_task_object']);