function update_get_projects in Drupal 6
Same name and namespace in other branches
- 7 modules/update/update.compare.inc \update_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 or theme). Other information like the specific version and install type (official release, dev snapshot, etc) is handled later in update_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} table using the 'update_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.
See also
update_calculate_project_data()
3 calls to update_get_projects()
- update_calculate_project_data in modules/
update/ update.compare.inc - Given the installed projects and the available release data retrieved from remote servers, calculate the current status.
- update_get_available in modules/
update/ update.module - Internal helper to try to get the update information from the cache if possible, and to refresh the cache when necessary.
- _update_refresh in modules/
update/ update.fetch.inc - Fetch project info via XML from a central server.
File
- modules/
update/ update.compare.inc, line 31 - Code required only when comparing available updates to existing data.
Code
function update_get_projects() {
static $projects = array();
if (empty($projects)) {
// Retrieve the projects from cache, if present.
$projects = update_project_cache('update_project_projects');
if (empty($projects)) {
// Still empty, so we have to rebuild the cache.
_update_process_info_list($projects, module_rebuild_cache(), 'module');
_update_process_info_list($projects, system_theme_data(), 'theme');
// Allow other modules to alter projects before fetching and comparing.
drupal_alter('update_projects', $projects);
// Cache the site's project data for at most 1 hour.
_update_cache_set('update_project_projects', $projects, time() + 3600);
}
}
return $projects;
}