You are here

function upgrade_status_refresh in Upgrade Status 5

Same name and namespace in other branches
  1. 6 upgrade_status.module \upgrade_status_refresh()
  2. 7 upgrade_status.module \upgrade_status_refresh()

Fetch project info via XML from a central server.

3 calls to upgrade_status_refresh()
upgrade_status_core_version_form_submit in ./upgrade_status.admin.inc
Set the new Drupal core version in a variable; refresh project data.
upgrade_status_get_available in ./upgrade_status.admin.inc
Internal helper to try to get the update information from the cache if possible, and to refresh the cache when necessary.
_upgrade_status_manual_status in ./upgrade_status.admin.inc
Menu callback to manually check the upgrade status.

File

./upgrade_status.admin.inc, line 572
Checks to see if your installed modules are available for the next major release of Drupal.

Code

function upgrade_status_refresh() {
  global $base_url;
  @set_time_limit(240);

  // Since we're fetching new available update data, we want to clear
  // everything in our cache, to ensure we recompute the status. Note that
  // this does not cause update_status_get_projects() to be recomputed twice
  // in the same page load (e.g. when manually checking) since that function
  // stashes its answer in a static array.
  upgrade_status_invalidate_cache();
  $available = array();
  $data = array();
  $version = variable_get('upgrade_status_core_version', UPGRADE_STATUS_CORE_VERSION);
  $projects = update_status_get_projects();
  foreach ($projects as $key => $project) {

    // No site key to avoid hi-jacking module usage statistics.
    $url = _upgrade_status_build_fetch_url($project, $version);
    $xml = drupal_http_request($url);
    if (isset($xml->data)) {
      $data[] = $xml->data;
    }
  }
  if ($data) {
    $parser = new update_status_xml_parser();
    $available = $parser
      ->parse($data);
    cache_set('upgrade_status_info', 'cache', serialize($available));
    variable_set('upgrade_status_last', time());
    watchdog('upgrade_status', t('Fetched information about all available new releases and updates.'), WATCHDOG_NOTICE, l('view', 'admin/logs/updates'));
  }
  else {
    watchdog('upgrade_status', 'Unable to fetch any information on available new releases and updates.', WATCHDOG_ERROR, l('view', 'admin/logs/updates'));
  }
  return $available;
}