function update_calculate_project_data

7.x update.compare.inc update_calculate_project_data($available)
6.x update.compare.inc update_calculate_project_data($available)

Calculates the current update status of all projects on the site.

The results of this function are expensive to compute, especially on sites with lots of modules or themes, since it involves a lot of comparisons and other operations. Therefore, we cache the results into the {cache_update} table using the 'update_project_data' cache ID. However, since this is not the data about available updates fetched from the network, it is ok to invalidate it somewhat quickly. If we keep this data for very long, site administrators are more likely to see incorrect results if they upgrade to a newer version of a module or theme but do not visit certain pages that automatically clear this cache.

Parameters

array $available: Data about available project releases.

Return value

An array of installed projects with current update status information.

See also

update_get_available()

update_get_projects()

update_process_project_info()

update_project_cache()

3 calls to update_calculate_project_data()
update_manager_update_form in drupal-7.x/modules/update/update.manager.inc
Form constructor for the update form of the Update Manager module.
update_requirements in drupal-7.x/modules/update/update.install
Implements hook_requirements().
update_status in drupal-7.x/modules/update/update.report.inc
Page callback: Generates a page about the update status of projects.

File

drupal-7.x/modules/update/update.compare.inc, line 335
Code required only when comparing available updates to existing data.

Code

function update_calculate_project_data($available) {
  // Retrieve the projects from cache, if present.
  $projects = update_project_cache('update_project_data');
  // If $projects is empty, then the cache must be rebuilt.
  // Otherwise, return the cached data and skip the rest of the function.
  if (!empty($projects)) {
    return $projects;
  }
  $projects = update_get_projects();
  update_process_project_info($projects);
  foreach ($projects as $project => $project_info) {
    if (isset($available[$project])) {
      update_calculate_project_update_status($project, $projects[$project], $available[$project]);
    }
    else {
      $projects[$project]['status'] = UPDATE_UNKNOWN;
      $projects[$project]['reason'] = t('No available releases found');
    }
  }
  // Give other modules a chance to alter the status (for example, to allow a
  // contrib module to provide fine-grained settings to ignore specific
  // projects or releases).
  drupal_alter('update_status', $projects);

  // Cache the site's update status for at most 1 hour.
  _update_cache_set('update_project_data', $projects, REQUEST_TIME + 3600);
  return $projects;
}