function rules_scheduler_queue_tasks

Queue tasks that are ready for execution.

Return value

bool TRUE if any queue items were created, otherwise FALSE.

2 calls to rules_scheduler_queue_tasks()
drush_rules_scheduler_tasks in rules_scheduler/rules_scheduler.drush.inc
Command callback for processing the rules_scheduler_tasks queue.
rules_scheduler_cron in rules_scheduler/rules_scheduler.module
Implements hook_cron().

File

rules_scheduler/rules_scheduler.module, line 180

Code

function rules_scheduler_queue_tasks() {
    $items_created = FALSE;
    // Limit adding tasks to 1000 per cron run.
    $result = db_select('rules_scheduler', 'r', array(
        'fetch' => PDO::FETCH_ASSOC,
    ))->fields('r')
        ->condition('date', time(), '<=')
        ->orderBy('date')
        ->range(0, 1000)
        ->execute();
    $queue = DrupalQueue::get('rules_scheduler_tasks');
    foreach ($result as $task) {
        // Add the task to the queue and remove the entry afterwards.
        if ($queue->createItem($task)) {
            $items_created = TRUE;
            rules_scheduler_task_handler($task)->afterTaskQueued();
        }
    }
    return $items_created;
}