commit fd12e1bc23f15e241d5a150c44589dd96de17e09 Author: Erik Stielstra Date: Sat Jun 29 09:52:35 2013 +0100 #4 diff --git a/core/includes/project.inc b/core/includes/project.inc index fd1886f..0cf2fe9 100644 --- a/core/includes/project.inc +++ b/core/includes/project.inc @@ -32,8 +32,6 @@ * @param $additional_whitelist * (optional) Array of additional elements to be collected from the .info.yml * file. Defaults to array(). - * - * @see update_get_projects() */ function drupal_project_process_info_list(&$projects, $list, $project_type, $status, $additional_whitelist = array()) { foreach ($list as $file) { @@ -191,57 +189,6 @@ function drupal_project_get_project_name($file) { } /** - * Determines version and type information for currently installed projects. - * - * Processes the list of projects on the system to figure out the currently - * installed versions, and other information that is required before we can - * compare against the available releases to produce the status report. - * - * @param $projects - * Array of project information from update_get_projects(). - */ -function drupal_project_process_project_info(&$projects) { - foreach ($projects as $key => $project) { - // Assume an official release until we see otherwise. - $install_type = 'official'; - - $info = $project['info']; - - if (isset($info['version'])) { - // Check for development snapshots - if (preg_match('@(dev|HEAD)@', $info['version'])) { - $install_type = 'dev'; - } - - // Figure out what the currently installed major version is. We need - // to handle both contribution (e.g. "5.x-1.3", major = 1) and core - // (e.g. "5.1", major = 5) version strings. - $matches = array(); - if (preg_match('/^(\d+\.x-)?(\d+)\..*$/', $info['version'], $matches)) { - $info['major'] = $matches[2]; - } - elseif (!isset($info['major'])) { - // This would only happen for version strings that don't follow the - // drupal.org convention. We let contribs define "major" in their - // .info.yml in this case, and only if that's missing would we hit this. - $info['major'] = -1; - } - } - else { - // No version info available at all. - $install_type = 'unknown'; - $info['version'] = t('Unknown'); - $info['major'] = -1; - } - - // Finally, save the results we care about into the $projects array. - $projects[$key]['existing_version'] = $info['version']; - $projects[$key]['existing_major'] = $info['major']; - $projects[$key]['install_type'] = $install_type; - } -} - -/** * Filters the project .info.yml data to only save attributes we need. * * @param array $info @@ -253,7 +200,7 @@ function drupal_project_process_project_info(&$projects) { * @return * Array of .info.yml file data we need for the update manager. * - * @see drupal_project_process_info_list(drupal_project_process_info_list + * @see drupal_project_process_info_list() */ function drupal_project_filter_project_info($info, $additional_whitelist = array()) { $whitelist = array( diff --git a/core/modules/update/update.compare.inc b/core/modules/update/update.compare.inc index 072d67b..daf9a0d 100644 --- a/core/modules/update/update.compare.inc +++ b/core/modules/update/update.compare.inc @@ -16,8 +16,8 @@ * 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 drupal_project_process_project_info() - * since that logic is only required when preparing the status report, not for + * 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 @@ -53,7 +53,7 @@ * - base_themes: If the project is a theme it contains an associative array * of all base-themes. * - * @see drupal_project_process_project_info() + * @see update_process_project_info() * @see update_calculate_project_data() * @see update_project_storage() */ @@ -81,7 +81,56 @@ function update_get_projects() { return $projects; } +/** + * Determines version and type information for currently installed projects. + * + * Processes the list of projects on the system to figure out the currently + * installed versions, and other information that is required before we can + * compare against the available releases to produce the status report. + * + * @param $projects + * Array of project information from update_get_projects(). + */ +function update_process_project_info(&$projects) { + foreach ($projects as $key => $project) { + // Assume an official release until we see otherwise. + $install_type = 'official'; + $info = $project['info']; + + if (isset($info['version'])) { + // Check for development snapshots + if (preg_match('@(dev|HEAD)@', $info['version'])) { + $install_type = 'dev'; + } + + // Figure out what the currently installed major version is. We need + // to handle both contribution (e.g. "5.x-1.3", major = 1) and core + // (e.g. "5.1", major = 5) version strings. + $matches = array(); + if (preg_match('/^(\d+\.x-)?(\d+)\..*$/', $info['version'], $matches)) { + $info['major'] = $matches[2]; + } + elseif (!isset($info['major'])) { + // This would only happen for version strings that don't follow the + // drupal.org convention. We let contribs define "major" in their + // .info.yml in this case, and only if that's missing would we hit this. + $info['major'] = -1; + } + } + else { + // No version info available at all. + $install_type = 'unknown'; + $info['version'] = t('Unknown'); + $info['major'] = -1; + } + + // Finally, save the results we care about into the $projects array. + $projects[$key]['existing_version'] = $info['version']; + $projects[$key]['existing_major'] = $info['major']; + $projects[$key]['install_type'] = $install_type; + } +} /** * Calculates the current update status of all projects on the site. @@ -101,9 +150,9 @@ function update_get_projects() { * @return * An array of installed projects with current update status information. * - * @see drupal_project_process_project_info() * @see update_get_available() * @see update_get_projects() + * @see update_process_project_info() * @see update_project_storage() */ function update_calculate_project_data($available) { @@ -115,7 +164,7 @@ function update_calculate_project_data($available) { return $projects; } $projects = update_get_projects(); - drupal_project_process_project_info($projects); + update_process_project_info($projects); foreach ($projects as $project => $project_info) { if (isset($available[$project])) { update_calculate_project_update_status($projects[$project], $available[$project]);