diff --git a/lib/Controller/Task.php b/lib/Controller/Task.php index 979b9c2a08..19cbbb6fb1 100644 --- a/lib/Controller/Task.php +++ b/lib/Controller/Task.php @@ -445,7 +445,11 @@ public function poll() // Update statements $updateSth = $db->prepare('UPDATE `task` SET status = :status WHERE taskId = :taskId'); - $updateStartSth = $db->prepare('UPDATE `task` SET status = :status, lastRunStartDt = :lastRunStartDt WHERE taskId = :taskId'); + if (DBVERSION < 133) + $updateStartSth = null; + else + $updateStartSth = $db->prepare('UPDATE `task` SET status = :status, lastRunStartDt = :lastRunStartDt WHERE taskId = :taskId'); + $updateFatalErrorSth = $db->prepare('UPDATE `task` SET status = :status, isActive = :isActive, lastRunMessage = :lastRunMessage WHERE taskId = :taskId'); // We loop until we have gone through without running a task @@ -473,11 +477,18 @@ public function poll() $this->getLog()->info('Running Task ' . $taskId); // Set to running - $updateStartSth->execute([ - 'taskId' => $taskId, - 'status' => \Xibo\Entity\Task::$STATUS_RUNNING, - 'lastRunStartDt' => $this->getDate()->getLocalDate(null, 'U') - ]); + if (DBVERSION < 133) { + $updateSth->execute([ + 'taskId' => $taskId, + 'status' => \Xibo\Entity\Task::$STATUS_RUNNING + ]); + } else { + $updateStartSth->execute([ + 'taskId' => $taskId, + 'status' => \Xibo\Entity\Task::$STATUS_RUNNING, + 'lastRunStartDt' => $this->getDate()->getLocalDate(null, 'U') + ]); + } $this->store->incrementStat('xtr', 'update'); // Pass to run. @@ -521,6 +532,10 @@ private function pollProcessTimeouts() { $db = $this->store->getConnection('xtr'); + // Not available before 133 (1.8.2) + if (DBVERSION < 133) + return; + // Get timed out tasks and deal with them $command = $db->prepare(' SELECT taskId, lastRunStartDt diff --git a/lib/Factory/TaskFactory.php b/lib/Factory/TaskFactory.php index 4ef93c6d47..6055aae03f 100644 --- a/lib/Factory/TaskFactory.php +++ b/lib/Factory/TaskFactory.php @@ -101,8 +101,14 @@ public function query($sortOrder = null, $filterBy = []) $params = array(); $sql = ' SELECT `taskId`, `name`, `status`, `pid`, `configFile`, `class`, `options`, `schedule`, - `lastRunDt`, `lastRunStartDt`, `lastRunMessage`, `lastRunStatus`, `lastRunDuration`, `lastRunExitCode`, + `lastRunDt`, `lastRunStatus`, `lastRunMessage`, `lastRunDuration`, `lastRunExitCode`, `isActive`, `runNow` + '; + + if (DBVERSION >= 133) + $sql .= ', `lastRunStartDt` '; + + $sql .= ' FROM `task` WHERE 1 = 1 ';