diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 6f81480..fec0659 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -1175,6 +1175,18 @@ function _locale_rebuild_js($langcode = NULL) { } /** + * Implement hook_update_filter_project_info_whitelist_alter(). + * + * Add interface translation specific info file keys to retention whitelist. + */ +function locale_update_filter_project_info_whitelist_alter(&$whitelist) { + $whitelist[] = 'interface translation project'; + $whitelist[] = 'interface translation server'; + $whitelist[] = 'interface translation url'; + $whitelist[] = 'interface translation pattern'; +} + +/** * Save locale specific date formats to the database. * * @param $langcode diff --git a/core/modules/update/update.compare.inc b/core/modules/update/update.compare.inc index b729750..cc37d21 100644 --- a/core/modules/update/update.compare.inc +++ b/core/modules/update/update.compare.inc @@ -37,11 +37,11 @@ function update_get_projects() { // Still empty, so we have to rebuild the cache. $module_data = system_rebuild_module_data(); $theme_data = system_rebuild_theme_data(); - _update_process_info_list($projects, $module_data, 'module', TRUE); - _update_process_info_list($projects, $theme_data, 'theme', TRUE); + _update_process_info_list($projects, $module_data, array('type' => 'module', 'status' => TRUE, 'category' => 'community')); + _update_process_info_list($projects, $theme_data, array('type' => 'theme', 'status' => TRUE, 'category' => 'community')); 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); + _update_process_info_list($projects, $module_data, array('type' => 'module', 'status' => FALSE, 'category' => 'community')); + _update_process_info_list($projects, $theme_data, array('type' => 'theme', 'status' => FALSE, 'category' => 'community')); } // Allow other modules to alter projects before fetching and comparing. drupal_alter('update_projects', $projects); @@ -70,19 +70,27 @@ function update_get_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. + * @param $conditions + * Array of filter conditions: + * 'type' The kind of data in the list (can be 'module' or 'theme'). + * 'status' Boolean that controls what status (enabled or disabled) to + * process out of the $list and add to the $projects array. + * 'hidden' (optional) Boolean indicating whether hidden modules should be + * included. + * 'category' (optional) The kind of project. + * Can be 'community' or 'interface translation' * * @see update_get_projects() */ -function _update_process_info_list(&$projects, $list, $project_type, $status) { +function _update_process_info_list(&$projects, $list, $conditions) { + // Set default filter conditions if required. + $default = array('hidden' => FALSE, 'category' => 'all'); + $conditions = array_merge($default, $conditions); + foreach ($list as $file) { // A disabled base theme of an enabled sub-theme still has all of its code // run by the sub-theme, so we include it in our "enabled" projects list. - if ($status && !$file->status && !empty($file->sub_themes)) { + if ($conditions['status'] && !$file->status && !empty($file->sub_themes)) { foreach ($file->sub_themes as $key => $name) { // Build a list of enabled sub-themes. if ($list[$key]->status) { @@ -97,7 +105,7 @@ function _update_process_info_list(&$projects, $list, $project_type, $status) { } } // Otherwise, just add projects of the proper status to our list. - elseif ($file->status != $status) { + elseif ($file->status != $conditions['status']) { continue; } @@ -107,7 +115,7 @@ function _update_process_info_list(&$projects, $list, $project_type, $status) { } // Skip if it's a hidden module or theme. - if (!empty($file->info['hidden'])) { + if (!$conditions['hidden'] && !empty($file->info['hidden'])) { continue; } @@ -121,6 +129,12 @@ function _update_process_info_list(&$projects, $list, $project_type, $status) { continue; } + // Skip this project if it doesn't have the right category. + $category = isset($file->info['interface translation project']) ? 'interface translation' : 'community'; + if ($category != $conditions['category'] && $project_category != 'all') { + continue; + } + // If we don't already know it, grab the change time on the .info file // itself. Note: we need to use the ctime, not the mtime (modification // time) since many (all?) tar implementations will go out of their way to @@ -147,9 +161,9 @@ function _update_process_info_list(&$projects, $list, $project_type, $status) { $project_display_type = 'core'; } else { - $project_display_type = $project_type; + $project_display_type = $conditions['type']; } - if (empty($status) && empty($file->enabled_sub_themes)) { + if (empty($conditions['status']) && empty($file->enabled_sub_themes)) { // If we're processing disabled modules or themes, append a suffix. // However, we don't do this to a a base theme with enabled // subthemes, since we treat that case as if it is enabled. @@ -168,6 +182,7 @@ function _update_process_info_list(&$projects, $list, $project_type, $status) { // Add list of base themes. $base_themes = !empty($file->base_themes) ? $file->base_themes : array(); } + 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. @@ -179,7 +194,7 @@ function _update_process_info_list(&$projects, $list, $project_type, $status) { 'datestamp' => $file->info['datestamp'], 'includes' => array($file->name => $file->info['name']), 'project_type' => $project_display_type, - 'project_status' => $status, + 'project_status' => $conditions['status'], 'sub_themes' => $sub_themes, 'base_themes' => $base_themes, ); @@ -200,7 +215,7 @@ function _update_process_info_list(&$projects, $list, $project_type, $status) { $projects[$project_name]['base_themes'] += $base_themes; } } - elseif (empty($status)) { + elseif (empty($conditions['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 @@ -221,6 +236,9 @@ function update_get_project_name($file) { if (isset($file->info['project'])) { $project_name = $file->info['project']; } + elseif (isset($file->info['interface translation project'])) { + $project_name = $file->info['interface translation project']; + } elseif (isset($file->info['package']) && (strpos($file->info['package'], 'Core') === 0)) { $project_name = 'drupal'; } @@ -775,15 +793,20 @@ function update_project_cache($cid) { * @see _update_process_info_list() */ function update_filter_project_info($info) { - $whitelist = array( - '_info_file_ctime', - 'datestamp', - 'major', - 'name', - 'package', - 'project', - 'project status url', - 'version', - ); + $whitelist = &drupal_static(__FUNCTION__); + if (!isset($whitelist)) { + $whitelist = array( + '_info_file_ctime', + 'datestamp', + 'major', + 'name', + 'package', + 'project', + 'project status url', + 'version', + ); + // Let other modules alter the whitelist to keep more information. + drupal_alter('update_filter_project_info_whitelist', $whitelist); + } return array_intersect_key($info, drupal_map_assoc($whitelist)); }