Index: includes/FeedsScheduler.inc =================================================================== --- includes/FeedsScheduler.inc (revision 1036) +++ includes/FeedsScheduler.inc (working copy) @@ -88,8 +88,9 @@ * If drupal_queue is present, only pushes refresh tasks to queue and * returns. If drupal_queue is not available, works off tasks. */ - public function cron() { + public function cron($importer_id = NULL, $bypass_queue = FALSE) { // Check and set scheduler semaphore, take time. + // Set semaphore for a cron or drush request. if (variable_get('feeds_scheduler_cron', FALSE)) { watchdog('FeedsScheduler', 'Last cron process did not finish.', array(), WATCHDOG_ERROR); } @@ -99,9 +100,10 @@ // Release schedule lock where the lock is older than 1 hour. db_query("UPDATE {feeds_schedule} SET scheduled = 0 WHERE scheduled < %d", FEEDS_REQUEST_TIME - 3600); + $importers = $importer_id ? array(feeds_importer($importer_id)) : feeds_importer_load_all(); // Iterate over feed importers, pick $num jobs for each of them and // schedule them. - if ($importers = feeds_importer_load_all()) { + if ($importers) { $num = $this->queue() ? variable_get('feeds_schedule_queue_num', 200) : variable_get('feeds_schedule_num', 5); foreach ($importers as $importer) { foreach ($importer->getScheduleCallbacks() as $callback) { @@ -109,7 +111,7 @@ if ($period != FEEDS_SCHEDULE_NEVER) { $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); + $this->schedule($job, $bypass_queue); // @todo Add time limit. } } @@ -195,10 +197,10 @@ * @param $job * A job array. */ - protected function schedule($job) { + protected function schedule($job, $bypass_queue = FALSE) { 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() && !$bypass_queue) { if (!$this->queue()->createItem($job)) { $this->unschedule($job); watchdog('FeedsScheduler', 'Error adding item to queue.', WATCHDOG_CRITICAL);