1 update.module update_cron()

Implements hook_cron().

File

core/modules/update/update.module, line 206
Handles update checking for Backdrop core and contributed projects.

Code

function update_cron() {
  // Check to see if we are running a test before checking for updates.
  if (!_update_checking_enabled()) {
    return;
  }

  // An update interval of 0 means manaul checking only.
  $frequency = config_get('update.settings', 'update_interval_days');
  if ($frequency == 0) {
    return;
  }

  $interval = 60 * 60 * 24 * $frequency;
  if ((REQUEST_TIME - state_get('update_last_check', 0)) > $interval) {
    // If the configured update interval has elapsed, we want to invalidate
    // the cached data for all projects, attempt to re-fetch, and trigger any
    // configured notifications about the new status.
    update_refresh();
    update_fetch_data();
  }
  else {
    // Otherwise, see if any individual projects are now stale or still
    // missing data, and if so, try to fetch the data.
    update_get_available(TRUE);
  }
  if ((REQUEST_TIME - state_get('update_last_email_notification', 0)) > $interval) {
    // If configured time between notifications elapsed, send email about
    // updates possibly available.
    module_load_include('inc', 'update', 'update.fetch');
    _update_cron_notify();
  }
}