You are here

function feed_import_base_cron in Feed Import 7.3

Same name and namespace in other branches
  1. 8 feed_import_base/feed_import_base.module \feed_import_base_cron()

Implements hook_cron().

1 call to feed_import_base_cron()
drush_feed_import_base_cron in feed_import_base/feed_import_base.drush.inc
Implements drush_COMMANDFILE_COMMANDNAME()

File

feed_import_base/feed_import_base.module, line 59
Basic settings for feed import base module

Code

function feed_import_base_cron() {

  // Check if cron import is enabled.
  if (variable_get('feed_import_use_cron', FALSE)) {
    $overlap = variable_get('feed_import_let_overlap', array());
    $running = variable_get('feed_import_import_running', array());

    // Check if we can import.
    if (_feed_import_base_cron_in_time()) {
      $feeds = array_filter(FeedImport::loadAllFeeds(), '_feed_import_base_feed_enabled');
      uasort($feeds, '_feed_import_base_sort_feeds');
      $to_import = NULL;
      foreach ($feeds as $name => $feed) {
        if (in_array($feed->entity, $overlap) || empty($running[$feed->entity]) || !in_array($name, $running[$feed->entity])) {
          $to_import = $feed;
          break;
        }
      }
      unset($feeds, $feed);
      if ($to_import) {
        _feed_import_base_process_feed($to_import);
        variable_set('feed_import_last_executed_import', REQUEST_TIME);
      }
    }
  }

  // Delete expired items.
  if (($d = variable_get('feed_import_delete_items_per_cron', 300)) > 0) {
    $d = FeedImport::deleteExpired($d);
    if ($d && variable_get('feed_import_reports', TRUE)) {
      watchdog('Feed Import', 'Deleted @count expired items', array(
        '@count' => $d,
      ), WATCHDOG_NOTICE);
    }
  }
}