[BUGFIX] Check for exceptions instead of number of affected rows 58/57358/2
authorGeorg Ringer <georg.ringer@gmail.com>
Sun, 24 Jun 2018 16:22:30 +0000 (18:22 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 6 Jul 2018 19:00:07 +0000 (21:00 +0200)
Saving a scheduler task without any changes leads to 0 affected
rows which must not be interpreted as an error.

Resolves: #85366
Releases: master, 8.7
Change-Id: I474e16478cb09ad4940aaab5fe1d3eb21498c4c4
Reviewed-on: https://review.typo3.org/57358
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Rudy Gnodde <rgn@windinternet.nl>
Tested-by: Rudy Gnodde <rgn@windinternet.nl>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/scheduler/Classes/Scheduler.php

index d8d8f2c..2768e22 100644 (file)
@@ -244,6 +244,7 @@ class Scheduler implements SingletonInterface, LoggerAwareInterface
      */
     public function saveTask(Task\AbstractTask $task)
     {
+        $result = true;
         $taskUid = $task->getTaskUid();
         if (!empty($taskUid)) {
             try {
@@ -265,14 +266,18 @@ class Scheduler implements SingletonInterface, LoggerAwareInterface
                 'task_group' => $task->getTaskGroup(),
                 'serialized_task_object' => serialize($task)
             ];
-            $result = GeneralUtility::makeInstance(ConnectionPool::class)
-                ->getConnectionForTable('tx_scheduler_task')
-                ->update(
-                    'tx_scheduler_task',
-                    $fields,
-                    ['uid' => $taskUid],
-                    ['serialized_task_object' => Connection::PARAM_LOB]
-                );
+            try {
+                GeneralUtility::makeInstance(ConnectionPool::class)
+                    ->getConnectionForTable('tx_scheduler_task')
+                    ->update(
+                        'tx_scheduler_task',
+                        $fields,
+                        ['uid' => $taskUid],
+                        ['serialized_task_object' => Connection::PARAM_LOB]
+                    );
+            } catch (\Doctrine\DBAL\DBALException $e) {
+                $result = false;
+            }
         } else {
             $result = false;
         }