Same name and namespace in other branches
  1. 10 core/modules/update/update.fetch.inc \_update_cron_notify()
  2. 7.x modules/update/update.fetch.inc \_update_cron_notify()
  3. 8.9.x core/modules/update/update.fetch.inc \_update_cron_notify()
  4. 9 core/modules/update/update.fetch.inc \_update_cron_notify()

Perform any notifications that should be done once cron fetches new data.

This method checks the status of the site using the new data and depending on the configuration of the site, notifies administrators via email if there are new releases or missing security updates.

See also

update_requirements()

1 call to _update_cron_notify()
update_cron in modules/update/update.module
Implementation of hook_cron().

File

modules/update/update.fetch.inc, line 150
Code required only when fetching information about available updates.

Code

function _update_cron_notify() {
  include_once './includes/install.inc';
  $status = update_requirements('runtime');
  $params = array();
  $notify_all = variable_get('update_notification_threshold', 'all') == 'all';
  foreach (array(
    'core',
    'contrib',
  ) as $report_type) {
    $type = 'update_' . $report_type;
    if (isset($status[$type]['severity']) && ($status[$type]['severity'] == REQUIREMENT_ERROR || $notify_all && $status[$type]['reason'] == UPDATE_NOT_CURRENT)) {
      $params[$report_type] = $status[$type]['reason'];
    }
  }
  if (!empty($params)) {
    $notify_list = variable_get('update_notify_emails', '');
    if (!empty($notify_list)) {
      $default_language = language_default();
      foreach ($notify_list as $target) {
        if ($target_user = user_load(array(
          'mail' => $target,
        ))) {
          $target_language = user_preferred_language($target_user);
        }
        else {
          $target_language = $default_language;
        }
        drupal_mail('update', 'status_notify', $target, $target_language, $params);
      }
    }
  }
}