function feeds_cron in Feeds 7.2
Same name and namespace in other branches
- 8.3 feeds.module \feeds_cron()
- 8.2 feeds.module \feeds_cron()
- 6 feeds.module \feeds_cron()
- 7 feeds.module \feeds_cron()
Implements hook_cron().
Related topics
1 call to feeds_cron()
- FeedsFileHTTPTestCase::testCachedFilesCleanupQueue in tests/
feeds_fetcher_http.test - Tests if the cron task for cleaning up cached files are run one at a time.
File
- ./
feeds.module, line 54 - Feeds - basic API functions and hook implementations.
Code
function feeds_cron() {
// Expire old log entries.
db_delete('feeds_log')
->condition('request_time', REQUEST_TIME - 604800, '<')
->execute();
// Find importers that need to be rescheduled.
$importers = feeds_reschedule();
if ($importers) {
// @todo Maybe we should queue this somehow as well. This could be potentially
// very long.
$sources = db_query("SELECT feed_nid, id FROM {feeds_source} WHERE id IN (:ids)", array(
':ids' => $importers,
));
foreach ($sources as $source) {
feeds_source($source->id, $source->feed_nid)
->schedule();
}
feeds_reschedule(FALSE);
}
// Sync the files in the cache directory with entries in the cache every now
// and then. By default: every six hours.
$last_check = variable_get('feeds_sync_cache_feeds_http_last_check');
$interval = variable_get('feeds_sync_cache_feeds_http_interval', 21600);
if ($last_check < REQUEST_TIME - $interval) {
// Check first if the task isn't already queued.
$queue = DrupalQueue::get('feeds_sync_cache_feeds_http');
if ($queue
->numberOfItems() < 1) {
// Queue sync task.
FeedsHTTPCache::getInstance('cache_feeds_http')
->startSync();
}
variable_set('feeds_sync_cache_feeds_http_last_check', REQUEST_TIME);
}
}