[BUGFIX] Check for exceptions instead of number of affected rows 91/57491/4
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:26:05 +0000 (21:26 +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/57491
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/scheduler/Classes/Scheduler.php

index 2b81ce7..954f98a 100644 (file)
@@ -249,6 +249,7 @@ class Scheduler implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function saveTask(Task\AbstractTask $task)
     {
+        $result = true;
         $taskUid = $task->getTaskUid();
         if (!empty($taskUid)) {
             try {
@@ -270,14 +271,18 @@ class Scheduler implements \TYPO3\CMS\Core\SingletonInterface
                 '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;
         }