You are here

function update_status_get_projects in Update Status 5.2

Same name and namespace in other branches
  1. 5 update_status.module \update_status_get_projects()

Fetch an array of installed and enabled projects.

This is only responsible for generating an array of projects (taking into account projects that include more than one module). Other information like the specific version and install type (official release, dev snapshot, etc) is handled later in update_status_process_project_info() since that logic is only required when preparing the status report, not for fetching the available release data.

This array is fairly expensive to construct, since it involves a lot of disk I/O, so we cache the results into the {cache_update_status} table using the 'update_status_project_projects' 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.

@todo Extend this to include themes and theme engines when they get .info files.

See also

update_status_process_project_info()

update_status_calculate_project_data()

update_status_project_cache()

3 calls to update_status_get_projects()
update_status_calculate_project_data in ./update_status.module
Given the installed projects and the available release data retrieved from remote servers, calculate the current status.
update_status_get_available in ./update_status.module
Internal helper to try to get the update information from the cache if possible, and to refresh the cache when necessary.
update_status_refresh in ./update_status.module
Fetch project info via XML from a central server.

File

./update_status.module, line 708

Code

function update_status_get_projects() {
  static $projects = array();
  if (!empty($projects)) {
    return $projects;
  }

  // Retrieve the projects from cache, if present.
  $projects = update_status_project_cache('update_status_project_projects');
  if (!empty($projects)) {
    return $projects;
  }

  // Still empty, will have to compute this and save it to the DB cache.
  // Get current list of modules.
  $files = drupal_system_listing('\\.module$', 'modules', 'name', 0);

  // Extract current files from database.
  system_get_files_database($files, 'module');
  _update_status_process_info_list($projects, $files, 'module');
  if (variable_get('update_status_check_disabled', FALSE)) {
    _update_status_process_info_list($projects, $files, 'disabled-module');
  }

  // Allow other modules to alter projects before fetching and comparing.
  foreach (module_implements('update_status_projects_alter') as $module) {
    $function = $module . '_update_status_projects_alter';
    $function($projects);
  }
  _update_status_cache_set('update_status_project_projects', serialize($projects), time() + 60 * 60);
  return $projects;
}