| Conditions | 3 |
| Paths | 4 |
| Total Lines | 26 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 2 |
| 1 | <?php |
||
| 26 | public function actionRerunAllFailedTasks() |
||
| 27 | { |
||
| 28 | // Get all failed tasks |
||
| 29 | $query = craft()->db->createCommand() |
||
| 30 | ->select('id') |
||
| 31 | ->from('tasks') |
||
| 32 | ->where(array('and', 'lft = 1', 'status = :status'), array(':status' => TaskStatus::Error)); |
||
| 33 | |||
| 34 | // Get all hanging? tasks |
||
| 35 | if ($timeout = craft()->config->get('taskTimeout')) { |
||
| 36 | $query->orWhere(array('and', 'lft = 1', 'dateCreated < (NOW() - INTERVAL :seconds SECOND)'), array(':seconds' => $timeout)); |
||
| 37 | } |
||
| 38 | |||
| 39 | // Get all |
||
| 40 | $tasks = $query->queryAll(); |
||
| 41 | |||
| 42 | // Loop through failed tasks |
||
| 43 | foreach ($tasks as $task) { |
||
| 44 | |||
| 45 | // Rerun task |
||
| 46 | craft()->tasks->rerunTaskById($task['id']); |
||
| 47 | } |
||
| 48 | |||
| 49 | // Run pending tasks controller |
||
| 50 | craft()->runController('tasks/runPendingTasks'); |
||
| 51 | } |
||
| 52 | } |
||
| 53 |