You are here

function revision_scheduler_cron in Revision scheduler 7

Implements hook_cron().

1 call to revision_scheduler_cron()
drush_revision_scheduler_process in ./revision_scheduler.drush.inc
Drush command callback for revision-scheduler-process.

File

./revision_scheduler.module, line 346

Code

function revision_scheduler_cron() {

  // Ensure that the items are ordered in the same method as
  // revision_scheduler_operation_uasort()
  if ($ids = db_query("SELECT * FROM {revision_scheduler} WHERE time_scheduled <= :now AND time_queued = 0 AND time_executed = 0 ORDER BY time_scheduled ASC, id ASC", array(
    ':now' => REQUEST_TIME,
  ))
    ->fetchCol()) {
    $queue = DrupalQueue::get('revision_scheduler');
    foreach ($ids as $id) {
      if ($queue
        ->createItem($id)) {
        db_update('revision_scheduler')
          ->fields(array(
          'time_queued' => time(),
        ))
          ->condition('id', $id)
          ->execute();
      }
    }
  }
}