Skip to content

Commit

Permalink
Merge pull request #270 from xibosignage/develop
Browse files Browse the repository at this point in the history
1.8.2 - fix upgrade
  • Loading branch information
dasgarner authored Jun 26, 2017
2 parents 66d5a20 + a20a39e commit 576b6b5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
27 changes: 21 additions & 6 deletions lib/Controller/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion lib/Factory/TaskFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
';
Expand Down

0 comments on commit 576b6b5

Please sign in to comment.