$result=db_query_range("SELECT feed_nid, id, callback, last_executed_time FROM {feeds_schedule} WHERE id = '%s' AND callback = '%s' AND scheduled = 0 AND (last_executed_time < %d OR last_executed_time = 0) ORDER BY last_executed_time ASC",$importer->id,$callback,FEEDS_REQUEST_TIME-$period,0,$num);
while($job=db_fetch_array($result)){
$this->schedule($job);
// @todo Add time limit.
}
}
}
}
}
// Unflag and post a message that we're done.
variable_set('feeds_scheduler_cron',FALSE);
watchdog('FeedsScheduler','Finished processing schedule after !time.',array('!time'=>format_interval(time()-$start)));
}
/**
* Implementation of FeedsSchedulerInterface::add().
*
* Add a feed to the scheduler.
*
* @todo Create optional parameter $last_executed_time to pass in. Set this
'scheduled'=>0,// Means NOT scheduled at the moment.
);
if(db_result(db_query_range("SELECT 1 FROM {feeds_schedule} WHERE id = '%s' AND callback = '%s' AND feed_nid = %d",$importer_id,$callback,$feed_nid,0,1))){
// Make sure that job is not scheduled after this method has executed.
$this->unschedule($job);
}
/**
* @return
* Drupal Queue if available, NULL otherwise.
*/
protectedfunctionqueue(){
if(module_exists('drupal_queue')){
drupal_queue_include();
returndrupal_queue_get(FEEDS_SCHEDULER_QUEUE);
}
}
/**
* Attempt to reserve a job. If successful work it off or - if Drupal Queue is
* available - queue it.
*
* The lock/release mechanism makes sure that an item does not get queued
* twice. It has a different purpose than the FeedsSource level locking
* which is in place to avoid concurrent import/clear operations on a source.
*
* @param $job
* A job array.
*/
protectedfunctionschedule($job){
db_query("UPDATE {feeds_schedule} SET scheduled = %d WHERE id = '%s' AND feed_nid = %d AND callback = '%s'",FEEDS_REQUEST_TIME,$job['id'],$job['feed_nid'],$job['callback']);
if(db_affected_rows()){
if($this->queue()){
if(!$this->queue()->createItem($job)){
$this->unschedule($job);
watchdog('FeedsScheduler','Error adding item to queue.',WATCHDOG_CRITICAL);
return;
}
}
else{
$this->work($job);
}
}
}
/**
* Remove a job from schedule.
*
* This function sets the source's scheduled bit to 0 and thus makes