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.28 diff -u -p -r1.28 update.compare.inc --- modules/update/update.compare.inc 22 Aug 2009 14:34:23 -0000 1.28 +++ modules/update/update.compare.inc 23 Aug 2009 06:46:03 -0000 @@ -36,8 +36,14 @@ function update_get_projects() { $projects = update_project_cache('update_project_projects'); if (empty($projects)) { // Still empty, so we have to rebuild the cache. - _update_process_info_list($projects, system_get_module_data(), 'module'); - _update_process_info_list($projects, system_get_theme_data(), 'theme'); + $module_data = system_get_module_data(); + $theme_data = system_get_theme_data(); + _update_process_info_list($projects, $module_data, 'module', TRUE); + _update_process_info_list($projects, $theme_data, 'theme', TRUE); + if (variable_get('update_check_disabled', FALSE)) { + _update_process_info_list($projects, $module_data, 'module', FALSE); + _update_process_info_list($projects, $theme_data, 'theme', FALSE); + } // 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. @@ -49,11 +55,33 @@ function update_get_projects() { /** * Populate an array of project data. + * + * This iterates over a list of the installed modules or themes and groups + * them by project and status. A few parts of this function assume that + * enabled modules and themes are always processed first, and if disabled + * modules or themes are being processed (there is a setting to control if + * disabled code should be included in the Available updates report or not), + * those are only processed after $projects has been populated with + * information about the enabled code. 'Hidden' modules are always + * ignored. This function also records the latest change time on the .info + * files for each module or theme, which is important data which is used when + * deciding if the cached available update data should be invalidated. + * + * @param $projects + * Reference to the array of project data of what's installed on this site. + * @param $list + * Array of data to process to add the relevant info to the $projects array. + * @param $project_type + * The kind of data in the list (can be 'module' or 'theme'). + * @param $status + * Boolean that controls what status (enabled or disabled) to process out of + * the $list and add to the $projects array. + * + * @see update_get_projects() */ -function _update_process_info_list(&$projects, $list, $project_type) { +function _update_process_info_list(&$projects, $list, $project_type, $status) { foreach ($list as $file) { - if (empty($file->status)) { - // Skip disabled modules or themes. + if ($file->status != $status) { continue; } @@ -62,6 +90,11 @@ function _update_process_info_list(&$pro continue; } + // Skip if it's a hidden module. + if (!empty($file->info['hidden'])) { + continue; + } + // If the .info doesn't define the 'project', try to figure it out. if (!isset($file->info['project'])) { $file->info['project'] = update_get_project_name($file); @@ -85,6 +118,21 @@ function _update_process_info_list(&$pro } $project_name = $file->info['project']; + + // Figure out what project type we're going to use to display this module + // or theme. If the project name is 'drupal', we don't want it to show up + // under the usual "Modules" section, we put it at a special "Drupal Core" + // section at the top of the report. + if ($project_name == 'drupal') { + $project_display_type = 'core'; + } + else { + $project_display_type = $project_type; + } + if (empty($status)) { + // If we're processing disabled modules or themes, append a suffix. + $project_display_type .= '-disabled'; + } if (!isset($projects[$project_name])) { // Only process this if we haven't done this project, since a single // project can have multiple modules or themes. @@ -93,13 +141,26 @@ function _update_process_info_list(&$pro 'info' => $file->info, 'datestamp' => isset($file->info['datestamp']) ? $file->info['datestamp'] : 0, 'includes' => array($file->name => $file->info['name']), - 'project_type' => $project_name == 'drupal' ? 'core' : $project_type, + 'project_type' => $project_display_type, + 'project_status' => $status, ); } - else { + elseif ($projects[$project_name]['project_type'] == $project_display_type) { + // Only add the file we're processing to the 'includes' array for this + // project if it is of the same type and status (which is encoded in the + // $project_display_type). This prevents listing all the disabled + // modules included with an enabled project if we happen to be checking + // for disabled modules, too. $projects[$project_name]['includes'][$file->name] = $file->info['name']; $projects[$project_name]['info']['_info_file_ctime'] = max($projects[$project_name]['info']['_info_file_ctime'], $file->info['_info_file_ctime']); } + elseif (empty($status)) { + // If we have a project_name that matches, but the project_display_type + // does not, it means we're processing a disabled module or theme that + // belongs to a project that has some enabled code. In this case, we add + // the disabled thing into a separate array for separate display. + $projects[$project_name]['disabled'][$file->name] = $file->info['name']; + } } } Index: modules/update/update.report.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.report.inc,v retrieving revision 1.19 diff -u -p -r1.19 update.report.inc --- modules/update/update.report.inc 22 Aug 2009 14:34:23 -0000 1.19 +++ modules/update/update.report.inc 23 Aug 2009 06:46:03 -0000 @@ -180,7 +180,18 @@ function theme_update_report($data) { $row .= '
'; sort($project['includes']); - $row .= t('Includes: %includes', array('%includes' => implode(', ', $project['includes']))); + if (!empty($project['disabled'])) { + sort($project['disabled']); + // Make sure we start with a clean slate for each project in the report. + $includes_items = array(); + $row .= t('Includes:'); + $includes_items[] = t('Enabled: %includes', array('%includes' => implode(', ', $project['includes']))); + $includes_items[] = t('Disabled: %disabled', array('%disabled' => implode(', ', $project['disabled']))); + $row .= theme('item_list', $includes_items); + } + else { + $row .= t('Includes: %includes', array('%includes' => implode(', ', $project['includes']))); + } $row .= "
\n"; $row .= "\n"; // info div. @@ -198,8 +209,8 @@ function theme_update_report($data) { 'core' => t('Drupal core'), 'module' => t('Modules'), 'theme' => t('Themes'), - 'disabled-module' => t('Disabled modules'), - 'disabled-theme' => t('Disabled themes'), + 'module-disabled' => t('Disabled modules'), + 'theme-disabled' => t('Disabled themes'), ); foreach ($project_types as $type_name => $type_label) { if (!empty($rows[$type_name])) { Index: modules/update/update.settings.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.settings.inc,v retrieving revision 1.7 diff -u -p -r1.7 update.settings.inc --- modules/update/update.settings.inc 16 Jul 2009 10:44:21 -0000 1.7 +++ modules/update/update.settings.inc 23 Aug 2009 06:46:03 -0000 @@ -43,6 +43,12 @@ function update_settings() { '#description' => t('You can choose to send e-mail only if a security update is available, or to be notified about all newer versions. If there are updates available of Drupal core or any of your installed modules and themes, your site will always print a message on the status report page, and will also display an error message on administration pages if there is a security update.', array('@status_report' => url('admin/reports/status'))) ); + $form['update_check_disabled'] = array( + '#type' => 'checkbox', + '#title' => t('Check for updates of disabled modules and themes'), + '#default_value' => variable_get('update_check_disabled', FALSE), + ); + $form = system_settings_form($form, FALSE); // Custom validation callback for the email notification setting. $form['#validate'][] = 'update_settings_validate'; @@ -87,6 +93,12 @@ function update_settings_validate($form, /** * Submit handler for the settings tab. + * + * Also invalidates the cache of available updates if the "Check for updates + * of disabled modules and themes" setting is being changed. The available + * updates report need to refetch available update data after this setting + * changes or it would show misleading things (e.g. listing the disabled + * projects on the site with the "No available releases found" warning). */ function update_settings_submit($form, $form_state) { $op = $form_state['values']['op']; @@ -100,5 +112,12 @@ function update_settings_submit($form, $ unset($form_state['notify_emails']); unset($form_state['values']['update_notify_emails']); + // See if the update_check_disabled setting is being changed, and if so, + // invalidate all cached update status data. + $check_disabled = variable_get('update_check_disabled', FALSE); + if ($form_state['values']['update_check_disabled'] != $check_disabled) { + _update_cache_clear(); + } + system_settings_form_submit($form, $form_state); }