public function Cron::checkTasks in Anti Spam by CleanTalk 9.1.x
Same name and namespace in other branches
- 8.4 src/lib/Cleantalk/Common/Cron.php \Cleantalk\Common\Cron::checkTasks()
Getting tasks which should be run
Return value
bool|array
File
- src/
lib/ Cleantalk/ Common/ Cron.php, line 165
Class
- Cron
- CleanTalk Cron class
Namespace
Cleantalk\CommonCode
public function checkTasks() {
// No tasks to run
if (empty($this->tasks)) {
return false;
}
$tasks_to_run = array();
foreach ($this->tasks as $task => &$task_data) {
if (!isset($task_data['processing'], $task_data['last_call']) || $task_data['processing'] === true && time() - $task_data['last_call'] > $this->task_execution_min_interval) {
$task_data['processing'] = false;
$task_data['last_call'] = 0;
}
if ($task_data['processing'] === false && $task_data['next_call'] <= time()) {
$task_data['processing'] = true;
$task_data['last_call'] = time();
$tasks_to_run[] = $task;
}
// Hard bug fix
if (!isset($task_data['params'])) {
$task_data['params'] = array();
}
}
unset($task_data);
$this
->saveTasks($this->tasks);
return $tasks_to_run;
}