function feedapi_cron in FeedAPI 5
Same name and namespace in other branches
- 6 feedapi.module \feedapi_cron()
Implementation of hook_cron().
1 string reference to 'feedapi_cron'
- feedapi_cron_time in ./feedapi.module 
- Check for time limits in cron processing.
File
- ./feedapi.module, line 610 
- Handle the submodules (for feed and item processing) Provide a basic management of feeds
Code
function feedapi_cron() {
  db_query('DELETE FROM {feedapi_stat} WHERE timestamp < %d', variable_get('cron_semaphore', FALSE) - FEEDAPI_CRON_STAT_LIFETIME);
  // Initialize counters
  $count = array(
    '%feeds' => 0,
    '%expired' => 0,
    '%new' => 0,
    '%updated' => 0,
  );
  // We get feeds in small lots, this will save memory and have the process adjusting to the
  // time limit even when we have many thousands of them.
  $start = time() - FEEDAPI_CRON_MIN_REFRESH_TIME;
  $process = 0;
  // The counter process will be > 0 if we've selected less feeds
  while (!$process && feedapi_cron_time()) {
    $process = FEEDAPI_CRON_FEEDS;
    $result = db_query_range("SELECT nid FROM {feedapi} WHERE checked <= %d AND skip = 0 ORDER BY checked", $start, 0, FEEDAPI_CRON_FEEDS);
    while (feedapi_cron_time() && ($feed = db_fetch_object($result))) {
      // Call the refresh process for each feed and store counters
      $counter = feedapi_invoke('refresh', $feed, TRUE);
      if ($counter) {
        foreach ($counter as $name => $value) {
          $count['%' . $name] += $value;
        }
      }
      $count['%feeds']++;
      $process--;
    }
  }
}