[BUGFIX] Ensure deleted scheduler tasks are never run 39/58439/5
authorBenni Mack <benni@typo3.org>
Sun, 30 Sep 2018 16:03:24 +0000 (18:03 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Sun, 30 Sep 2018 19:36:16 +0000 (21:36 +0200)
In #79777 a new "tx_scheduler_task.deleted" field was
added, but is not always considered when tasks are run.

Resolves: #86420
Related: #79777
Releases: master
Change-Id: Ide025bda13504bd56dc5f9cc090f5e7e54da6695
Reviewed-on: https://review.typo3.org/58439
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/scheduler/Classes/Scheduler.php

index d15cd66..777a4ef 100644 (file)
@@ -110,7 +110,8 @@ class Scheduler implements SingletonInterface, LoggerAwareInterface
                 $queryBuilder->expr()->neq(
                     'serialized_executions',
                     $queryBuilder->createNamedParameter('', \PDO::PARAM_STR)
-                )
+                ),
+                $queryBuilder->expr()->eq('deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))
             )
             ->execute();
         $maxDuration = $this->extConf['maxLifetime'] * 60;
@@ -322,11 +323,13 @@ class Scheduler implements SingletonInterface, LoggerAwareInterface
                 $queryBuilder->expr()->orX(
                     $queryBuilder->expr()->eq('g.hidden', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
                     $queryBuilder->expr()->isNull('g.hidden')
-                )
+                ),
+                $queryBuilder->expr()->eq('t.deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))
             );
         } else {
             $queryBuilder->where(
-                $queryBuilder->expr()->eq('t.uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT))
+                $queryBuilder->expr()->eq('t.uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)),
+                $queryBuilder->expr()->eq('t.deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))
             );
         }
 
@@ -369,9 +372,15 @@ class Scheduler implements SingletonInterface, LoggerAwareInterface
      */
     public function fetchTaskRecord($uid)
     {
-        $row = GeneralUtility::makeInstance(ConnectionPool::class)
-            ->getConnectionForTable('tx_scheduler_task')
-            ->select(['*'], 'tx_scheduler_task', ['uid' => (int)$uid])
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
+            ->getQueryBuilderForTable('tx_scheduler_task');
+        $row = $queryBuilder->select('*')
+            ->from('tx_scheduler_task')
+            ->where(
+                $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter((int)$uid, \PDO::PARAM_INT)),
+                $queryBuilder->expr()->eq('deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))
+            )
+            ->execute()
             ->fetch();
 
         // If the task is not found, throw an exception