function update_get_available in Drupal 6
Same name and namespace in other branches
- 8 core/modules/update/update.module \update_get_available()
- 7 modules/update/update.module \update_get_available()
- 9 core/modules/update/update.module \update_get_available()
- 10 core/modules/update/update.module \update_get_available()
Internal helper to try to get the update information from the cache if possible, and to refresh the cache when necessary.
In addition to checking the cache lifetime, this function also ensures that there are no .info files for enabled modules or themes that have a newer modification timestamp than the last time we checked for available update data. If any .info file was modified, it almost certainly means a new version of something was installed. Without fresh available update data, the logic in update_calculate_project_data() will be wrong and produce confusing, bogus results.
Parameters
$refresh: Boolean to indicate if this method should refresh the cache automatically if there's no data.
See also
2 calls to update_get_available()
- update_requirements in modules/
update/ update.module - Implementation of hook_requirements().
- update_status in modules/
update/ update.report.inc - Menu callback. Generate a page about the update status of projects.
File
- modules/
update/ update.module, line 350 - The "Update status" module checks for available updates of Drupal core and any installed contributed modules and themes. It warns site administrators if newer releases are available via the system status report (admin/reports/status), the…
Code
function update_get_available($refresh = FALSE) {
module_load_include('inc', 'update', 'update.compare');
$available = array();
// First, make sure that none of the .info files have a change time
// newer than the last time we checked for available updates.
$needs_refresh = FALSE;
$last_check = variable_get('update_last_check', 0);
$projects = update_get_projects();
foreach ($projects as $key => $project) {
if ($project['info']['_info_file_ctime'] > $last_check) {
$needs_refresh = TRUE;
break;
}
}
if (!$needs_refresh && ($cache = _update_cache_get('update_available_releases')) && $cache->expire > time()) {
$available = $cache->data;
}
elseif ($needs_refresh || $refresh) {
// If we need to refresh due to a newer .info file, ignore the argument
// and force the refresh (e.g., even for update_requirements()) to prevent
// bogus results.
$available = update_refresh();
}
return $available;
}