function announcements_feed_cron

Same name in other branches
  1. 10 core/modules/announcements_feed/announcements_feed.module \announcements_feed_cron()
  2. 11.x core/modules/announcements_feed/announcements_feed.module \announcements_feed_cron()

Implements hook_cron().

File

modules/announcements_feed/announcements_feed.module, line 164

Code

function announcements_feed_cron() {
    module_load_include('inc', 'announcements_feed', 'announcements_feed');
    $cron_interval = variable_get('announcements_feed_cron_interval', ANNOUNCEMENTS_FEED_DEFAULT_CRON_INTERVAL);
    $last_check = variable_get('announcements_feed_last_fetch', 0);
    $time = time();
    if ($time - $last_check > $cron_interval) {
        try {
            announcements_feed_fetch(TRUE);
            // Update the last_fetch variable to the current time.
            variable_set('announcements_feed_last_fetch', $time);
        } catch (Exception $e) {
            watchdog('announcements_feed', 'Exception occurred: @message', array(
                '@message' => $e->getMessage(),
            ), WATCHDOG_ERROR);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.