cvs diff: Diffing modules/update Index: modules/update/update.compare.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.compare.inc,v retrieving revision 1.1 diff -u -p -r1.1 update.compare.inc --- modules/update/update.compare.inc 11 Jul 2007 15:15:40 -0000 1.1 +++ modules/update/update.compare.inc 26 Dec 2007 17:52:17 -0000 @@ -215,19 +215,52 @@ function update_calculate_project_data($ if (isset($available[$project])) { // Figure out the target major version. $existing_major = $project_info['existing_major']; - if (isset($available[$project]['default_major'])) { - $default_major = $available[$project]['default_major']; - $target_major = max($existing_major, $default_major); + if (isset($available[$project]['supported_majors']) && + in_array($existing_major, explode(',', $available[$project]['supported_majors']))) { + // Still supported, stay at the current major version. + $target_major = $existing_major; + } + elseif (isset($available[$project]['recommended_major'])) { + // Since 'recommended_major' is defined, we know this is the new XML + // format. Therefore, we know the current release is unsupported since + // its major version was not in the 'supported_majors' list. We should + // find the best release from the recommended major version. + $target_major = $available[$project]['recommended_major']; + $projects[$project]['status'] = UPDATE_NOT_SUPPORTED; + } + elseif (isset($available[$project]['default_major'])) { + // Older release history XML file without supported or recommended. + $target_major = $available[$project]['default_major']; } else { + // Malformed XML file? Stick with the current version. $target_major = $existing_major; } + // Make sure we never tell the admin to downgrade. + $target_major = max($existing_major, $target_major); $version_patch_changed = ''; $patch = ''; foreach ($available[$project]['releases'] as $version => $release) { - // Ignore unpublished releases. + // First, if this is the existing release, check a few conditions. + if ($projects[$project]['existing_version'] == $version) { + if (isset($release['terms']) && + isset($release['terms']['Release type']) && + in_array('Insecure', $release['terms']['Release type'])) { + $projects[$project]['status'] = UPDATE_NOT_SECURE; + } + elseif ($release['status'] != 'published') { + $projects[$project]['status'] = UPDATE_NOT_AVAILABLE; + } + elseif (isset($release['terms']) && + isset($release['terms']['Release type']) && + in_array('Unsupported', $release['terms']['Release type'])) { + $projects[$project]['status'] = UPDATE_NOT_SUPPORTED; + } + } + + // Otherwise, ignore unpublished releases. if ($release['status'] != 'published') { continue; } @@ -344,45 +377,40 @@ function update_calculate_project_data($ continue; } - // Check based upon install type and the site-wide threshold setting. - $error_level = variable_get('update_notification_threshold', 'all'); - - switch ($projects[$project]['install_type']) { - case 'official': - if ($projects[$project]['existing_version'] == $projects[$project]['recommended'] || $projects[$project]['existing_version'] == $projects[$project]['latest_version']) { - $projects[$project]['status'] = UPDATE_CURRENT; - } - else { - if (!empty($projects[$project]['security updates'])) { - $projects[$project]['status'] = UPDATE_NOT_SECURE; + // Figure out the status, based on what we've seen and the install type. + if (!empty($projects[$project]['security updates'])) { + // If we found security updates, that always trumps any other status. + $projects[$project]['status'] = UPDATE_NOT_SECURE; + } + elseif (!isset($projects[$project]['status'])) { + switch ($projects[$project]['install_type']) { + case 'official': + if ($projects[$project]['existing_version'] == $projects[$project]['recommended'] || $projects[$project]['existing_version'] == $projects[$project]['latest_version']) { + $projects[$project]['status'] = UPDATE_CURRENT; } else { $projects[$project]['status'] = UPDATE_NOT_CURRENT; } - } - break; - case 'dev': - if (!empty($projects[$project]['security updates'])) { - $projects[$project]['status'] = UPDATE_NOT_SECURE; break; - } - $latest = $available[$project]['releases'][$projects[$project]['latest_dev']]; - if (empty($projects[$project]['datestamp'])) { - $projects[$project]['status'] = UPDATE_NOT_CHECKED; - $projects[$project]['reason'] = t('Unknown release date'); - } - elseif (($projects[$project]['datestamp'] + 100 > $latest['date'])) { - $projects[$project]['status'] = UPDATE_CURRENT; - } - else { - $projects[$project]['status'] = UPDATE_NOT_CURRENT; - } - break; + case 'dev': + $latest = $available[$project]['releases'][$projects[$project]['latest_dev']]; + if (empty($projects[$project]['datestamp'])) { + $projects[$project]['status'] = UPDATE_NOT_CHECKED; + $projects[$project]['reason'] = t('Unknown release date'); + } + elseif (($projects[$project]['datestamp'] + 100 > $latest['date'])) { + $projects[$project]['status'] = UPDATE_CURRENT; + } + else { + $projects[$project]['status'] = UPDATE_NOT_CURRENT; + } + break; - default: - $projects[$project]['status'] = UPDATE_UNKNOWN; - $projects[$project]['reason'] = t('Invalid info'); + default: + $projects[$project]['status'] = UPDATE_UNKNOWN; + $projects[$project]['reason'] = t('Invalid info'); + } } } else { Index: modules/update/update.module =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.module,v retrieving revision 1.7 diff -u -p -r1.7 update.module --- modules/update/update.module 14 Dec 2007 18:08:49 -0000 1.7 +++ modules/update/update.module 26 Dec 2007 17:52:17 -0000 @@ -17,29 +17,40 @@ define('UPDATE_DEFAULT_URL', 'http://upd // These are internally used constants for this code, do not modify. /** - * Project is up to date. + * Project is missing security update(s). */ -define('UPDATE_CURRENT', 1); +define('UPDATE_NOT_SECURE', 1); /** - * Project is missing security update(s). + * Current release has been unpublished and is no longer available. */ -define('UPDATE_NOT_SECURE', 2); +define('UPDATE_NOT_AVAILABLE', 2); + +/** + * Current release is no longer supported by the project maintainer. + */ +define('UPDATE_NOT_SUPPORTED', 3); /** * Project has a new release available, but it is not a security release. */ -define('UPDATE_NOT_CURRENT', 3); +define('UPDATE_NOT_CURRENT', 4); + +/** + * Project is up to date. + */ +define('UPDATE_CURRENT', 5); /** * Project's status cannot be checked. */ -define('UPDATE_NOT_CHECKED', 4); +define('UPDATE_NOT_CHECKED', -1); /** * No available update data was found for project. */ -define('UPDATE_UNKNOWN', 5); +define('UPDATE_UNKNOWN', -2); + /** * Implementation of hook_help(). @@ -185,13 +196,6 @@ function update_requirements($phase) { include_once './modules/update/update.compare.inc'; $data = update_calculate_project_data($available); switch ($data['drupal']['status']) { - case UPDATE_NOT_CURRENT: - $requirements['update_core']['value'] = t('Out of date (version @version available)', array('@version' => $data['drupal']['recommended'])); - $requirements['update_core']['severity'] = $notification_level == 'all' ? REQUIREMENT_ERROR : REQUIREMENT_WARNING; - $requirements['update_core']['reason'] = UPDATE_NOT_CURRENT; - $requirements['update_core']['description'] = _update_message_text('core', UPDATE_NOT_CURRENT, TRUE); - break; - case UPDATE_NOT_SECURE: $requirements['update_core']['value'] = t('Not secure! (version @version available)', array('@version' => $data['drupal']['recommended'])); $requirements['update_core']['severity'] = REQUIREMENT_ERROR; @@ -199,12 +203,32 @@ function update_requirements($phase) { $requirements['update_core']['description'] = _update_message_text('core', UPDATE_NOT_SECURE, TRUE); break; + case UPDATE_NOT_AVAILABLE: + $requirements['update_core']['value'] = t('Not available! (version @version recommended)', array('@version' => $data['drupal']['recommended'])); + $requirements['update_core']['severity'] = REQUIREMENT_ERROR; + $requirements['update_core']['reason'] = UPDATE_NOT_AVAILABLE; + $requirements['update_core']['description'] = _update_message_text('core', UPDATE_NOT_AVAILABLE, TRUE); + break; + + case UPDATE_NOT_SUPPORTED: + // Impossible, core only ever has a single branch. + break; + + case UPDATE_NOT_CURRENT: + $requirements['update_core']['value'] = t('Out of date (version @version available)', array('@version' => $data['drupal']['recommended'])); + $requirements['update_core']['severity'] = $notification_level == 'all' ? REQUIREMENT_ERROR : REQUIREMENT_WARNING; + $requirements['update_core']['reason'] = UPDATE_NOT_CURRENT; + $requirements['update_core']['description'] = _update_message_text('core', UPDATE_NOT_CURRENT, TRUE); + break; + default: $requirements['update_core']['value'] = t('Up to date'); break; } // We don't want to check drupal a second time. unset($data['drupal']); + $not_available = FALSE; + $not_supported = FALSE; $not_current = FALSE; if (!empty($data)) { $requirements['update_contrib']['title'] = t('Module and theme update status'); @@ -212,19 +236,43 @@ function update_requirements($phase) { $requirements['update_contrib']['value'] = t('Up to date'); foreach (array_keys($data) as $project) { if (isset($available[$project])) { - if ($data[$project]['status'] == UPDATE_NOT_SECURE) { - $requirements['update_contrib']['value'] = t('Not secure!'); - $requirements['update_contrib']['severity'] = REQUIREMENT_ERROR; - $requirements['update_contrib']['reason'] = UPDATE_NOT_SECURE; - $requirements['update_contrib']['description'] = _update_message_text('contrib', UPDATE_NOT_SECURE, TRUE); - break; - } - elseif ($data[$project]['status'] == UPDATE_NOT_CURRENT) { - $not_current = TRUE; + switch ($data[$project]['status']) { + case UPDATE_NOT_SECURE: + $requirements['update_contrib']['value'] = t('Not secure!'); + $requirements['update_contrib']['severity'] = REQUIREMENT_ERROR; + $requirements['update_contrib']['reason'] = UPDATE_NOT_SECURE; + $requirements['update_contrib']['description'] = _update_message_text('contrib', UPDATE_NOT_SECURE, TRUE); + // This is what we'll print, no need to continue the foreach. + break 2; + case UPDATE_NOT_AVAILABLE: + $not_available = TRUE; + break; + case UPDATE_NOT_SUPPORTED: + $not_supported = TRUE; + break; + case UPDATE_NOT_CURRENT: + $not_current = TRUE; + break; } } } - if (!isset($requirements['update_contrib']['severity']) && $not_current) { + // Depending on what we saw, print out the right message. + if (isset($requirements['update_contrib']['severity'])) { + // We already found an insecure project, nothing more to say. + } + elseif ($not_available) { + $requirements['update_contrib']['severity'] = REQUIREMENT_ERROR; + $requirements['update_contrib']['value'] = t('Unavailable release'); + $requirements['update_contrib']['reason'] = UPDATE_NOT_AVAILABLE; + $requirements['update_contrib']['description'] = _update_message_text('contrib', UPDATE_NOT_AVAILABLE, TRUE); + } + elseif ($not_supported) { + $requirements['update_contrib']['severity'] = REQUIREMENT_ERROR; + $requirements['update_contrib']['value'] = t('Unsupported release'); + $requirements['update_contrib']['reason'] = UPDATE_NOT_SUPPORTED; + $requirements['update_contrib']['description'] = _update_message_text('contrib', UPDATE_NOT_SUPPORTED, TRUE); + } + elseif ($not_current) { $requirements['update_contrib']['severity'] = $notification_level == 'all' ? REQUIREMENT_ERROR : REQUIREMENT_WARNING; $requirements['update_contrib']['value'] = t('Out of date'); $requirements['update_contrib']['reason'] = UPDATE_NOT_CURRENT; @@ -368,21 +416,37 @@ function _update_message_text($msg_type, $langcode = isset($language) ? $language->language : NULL; $text = ''; switch ($msg_reason) { - case UPDATE_NOT_CURRENT: + case UPDATE_NOT_SECURE: if ($msg_type == 'core') { - $text = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.', array(), $langcode); + $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', array(), $langcode); } else { - $text = t('There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.', array(), $langcode); + $text = t('There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!', array(), $langcode); } break; - case UPDATE_NOT_SECURE: + case UPDATE_NOT_AVAILABLE: if ($msg_type == 'core') { - $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', array(), $langcode); + $text = t('Your version of Drupal is no longer available. Upgrading is highly advised!', array(), $langcode); } else { - $text = t('There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!', array(), $langcode); + $text = t('The installed version of at least one of your modules or themes is no longer available. Upgrading is highly advised!', array(), $langcode); + } + break; + + case UPDATE_NOT_SUPPORTED: + // Core only ever has a single branch, so this can never happen. + if ($msg_type != 'core') { + $text = t('The installed version of at least one of your modules or themes is no longer supported. Upgrading is highly advised! Please see the project homepage for more details.', array(), $langcode); + } + break; + + case UPDATE_NOT_CURRENT: + if ($msg_type == 'core') { + $text = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.', array(), $langcode); + } + else { + $text = t('There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.', array(), $langcode); } break; } Index: modules/update/update.report.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.report.inc,v retrieving revision 1.6 diff -u -p -r1.6 update.report.inc --- modules/update/update.report.inc 20 Dec 2007 08:42:05 -0000 1.6 +++ modules/update/update.report.inc 26 Dec 2007 17:52:17 -0000 @@ -48,9 +48,11 @@ function theme_update_report($data) { $icon = theme('image', 'misc/watchdog-ok.png'); break; case UPDATE_NOT_SECURE: + case UPDATE_NOT_AVAILABLE: + case UPDATE_NOT_SUPPORTED: case UPDATE_NOT_CURRENT: if ($notification_level == 'all' - || $project['status'] == UPDATE_NOT_SECURE) { + || $project['status'] != UPDATE_NOT_CURRENT) { $class = 'error'; $icon = theme('image', 'misc/watchdog-error.png'); break; @@ -64,16 +66,30 @@ function theme_update_report($data) { $row = '