Index: modules/update_status/update_status.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/update_status/update_status.module,v retrieving revision 1.55 diff -u -p -r1.55 update_status.module --- modules/update_status/update_status.module 20 Jun 2007 04:55:21 -0000 1.55 +++ modules/update_status/update_status.module 20 Jun 2007 06:41:00 -0000 @@ -256,6 +256,16 @@ function update_status_force_status() { /** * Fetch an array of installed and enabled projects. * + * This is only responsible for generating an array of projects (taking into + * account projects that include more than one module). Other information + * like the specific version and install type (official release, dev snapshot, + * etc) is handled later in update_status_process_project_info() since that + * logic is only required when preparing the status report, not for fetching + * the available release data. + * + * @see update_status_process_project_info() + * @see update_status_calculate_project_data() + * * @todo * Extend this to include themes and theme engines when they get .info files. */ @@ -280,60 +290,97 @@ function update_status_get_projects() { continue; } - // Give other modules a chance to fill-in and clean the version. - // We can't use module_invoke_all() since we pass a reference to the - // hook so it can modify the version string. - foreach (module_implements('version_alter') as $module) { - $function = $module .'_version_alter'; - $function($file->info['version'], $file); - } - $info = $file->info; $info['check'] = TRUE; + if (!isset($info['project'])) { - // If we don't know the project yet, first see if this is core: - if (isset($info['package']) && (strpos($info['package'], 'Core -') !== FALSE)) { - $info['project'] = 'drupal'; - } - else { - // This isn't a core module, so guess the project from the directory. - $last = ''; - foreach (array_reverse(explode('/', $file->filename)) as $dir) { - if ($dir == 'modules') { - break; - } - $last = $dir; - } - if ($last) { - $info['project'] = $last; - } - else { - continue; - } - } + $info['project'] = update_status_get_project($file); } if (!isset($projects[$info['project']])) { // Only process this if we haven't done this project, since a single // project can have multiple modules. + $projects[$info['project']] = array( + 'name' => $info['project'], + 'info' => $info, + 'datestamp' => isset($info['datestamp']) ? $info['datestamp'] : 0, + 'filename' => $file->filename, + 'modules' => array($file->name => $info['name']), + ); + } + else { + $projects[$info['project']]['modules'][$file->name] = $info['name']; + } + } + asort($projects); + return $projects; +} - // Assume an official release until we see otherwise. - $type = 'official'; - - if (!isset($info['version'])) { - $type = 'unknown'; - $info['version'] = t('Unknown'); - } - elseif (strpos($info['version'], 'dev') !== FALSE) { - $type = 'dev'; +/** + * Given a $module object (as returned by system_get_files_database()), figure + * out what project that module belongs to. + * + * @see system_get_files_database() + */ +function update_status_get_project($module) { + $project = ''; + if (isset($module->info['project'])) { + $project = $module->info['project']; + } + elseif (isset($module->info['package']) + && (strpos($module->info['package'], 'Core -') !== FALSE)) { + $project = 'drupal'; + } + else { + // This isn't a core module, so guess the project from the directory. + $last = ''; + foreach (array_reverse(explode('/', $module->filename)) as $dir) { + if ($dir == 'modules') { + break; } + $last = $dir; + } + if ($last) { + $project = $last; + } + else { + continue; + } + } + return $project; +} + +/** + * Process 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_status_get_projects(). + */ +function update_status_process_project_info(&$projects) { + foreach ($projects as $key => $project) { + // Assume an official release until we see otherwise. + $type = 'official'; - if (!isset($info['project status url'])) { - $info['project status url'] = UPDATE_STATUS_DEFAULT_URL; + $info = $project['info']; + + // Give other modules a chance to fill-in and clean the version. + // We can't use module_invoke_all() since we pass a reference to + // the hook so it can modify the version string. + foreach (module_implements('version_alter') as $module) { + $function = $module .'_version_alter'; + $function($info['version'], $project); + } + + if (isset($info['version'])) { + // Check for development snapshots + if (strpos($info['version'], 'dev') !== FALSE) { + $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 + // 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)) { @@ -345,22 +392,20 @@ function update_status_get_projects() { // .info in this case, and only if that's missing would we hit this. $info['major'] = -1; } - $projects[$info['project']] = array( - 'name' => $info['project'], - 'existing_version' => $info['version'], - 'existing_major' => $info['major'], - 'project status url' => $info['project status url'], - 'type' => $type, - 'modules' => array($file->name => $info['name']), - 'datestamp' => isset($info['datestamp']) ? $info['datestamp'] : 0, - ); } else { - $projects[$info['project']]['modules'][$file->name] = $info['name']; + // No version info available at all. + $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]['type'] = $type; + unset($projects[$key]['info']); } - asort($projects); - return $projects; } /** @@ -417,9 +462,12 @@ function update_status_get_projects() { * Array of data about available project releases. * * @see update_status_get_available() + * @see update_status_get_projects() + * @see update_status_process_project_info() */ function update_status_calculate_project_data($avail) { $projects = update_status_get_projects(); + update_status_process_project_info($projects); $settings = variable_get('update_status_settings', array()); foreach ($projects as $project => $project_info) { if (isset($avail[$project])) { @@ -722,7 +770,10 @@ function update_status_refresh() { $data = array(); $projects = update_status_get_projects(); foreach ($projects as $key => $project) { - $url = $project['project status url'] .'/'. $key .'/'. UPDATE_STATUS_CORE_VERSION; + if (!isset($project['info']['project status url'])) { + $project['info']['project status url'] = UPDATE_STATUS_DEFAULT_URL; + } + $url = $project['info']['project status url'] .'/'. $key .'/'. UPDATE_STATUS_CORE_VERSION; $xml = drupal_http_request($url); $data[] = $xml->data; } Index: modules/cvs_deploy/cvs_deploy.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cvs_deploy/cvs_deploy.module,v retrieving revision 1.7 diff -u -p -r1.7 cvs_deploy.module --- modules/cvs_deploy/cvs_deploy.module 18 Jun 2007 08:19:42 -0000 1.7 +++ modules/cvs_deploy/cvs_deploy.module 20 Jun 2007 06:41:00 -0000 @@ -1,5 +1,5 @@ filename) .'/CVS'; + // The .info file contains no version data. Find the version based + // on the sticky tag in the local workspace (the CVS/Tag file). + $cvs_dir = dirname($project['filename']) .'/CVS'; if (is_dir($cvs_dir)) { $tag = ''; // If there's no Tag file, there's no tag, a.k.a. HEAD. if (file_exists($cvs_dir .'/Tag')) { @@ -59,12 +60,25 @@ function cvs_deploy_version_alter(&$vers } // The weird concatenation prevents CVS from 'expanding' this $Name. elseif (preg_match('/\$'.'Name: (.*?)\$/', $version, $match)) { - // If we matched $Name, we know this is from CVS, so we can try to - // make a human-readable version string. We can assume at least - // 5.x, which simplifies things. Core doesn't use $Name for - // version strings at all, so we can also assume contrib. $version = cvs_deploy_version_from_tag(trim($match[1])); } + + if (module_exists('update_status') && $version == 'HEAD') { + // If there's available update_status data, we can use the version string + // the release node pointing to HEAD really has. + if (empty($available)) { + $available = update_status_get_available(); + } + $project_name = isset($project['project']) ? $project['project'] : $project['name']; + if (isset($available[$project_name]['releases'])) { + foreach ($available[$project_name]['releases'] as $release) { + if (isset($release['tag']) && $release['tag'] == 'HEAD') { + $version = $release['version']; + break; + } + } + } + } } /** @@ -76,9 +90,15 @@ function cvs_deploy_version_alter(&$vers function cvs_deploy_form_alter($form_id, &$form) { if ($form_id == 'system_modules') { $files = $form['validation_modules']['#value']; - foreach ($files as $filename => $file) { - cvs_deploy_version_alter($file->info['version'], $file); - $form['version'][$filename]['#value'] = $file->info['version']; + foreach ($files as $modulename => $file) { + $project = array(); + if (module_exists('update_status')) { + $project['project'] = update_status_get_project($file); + } + $project['filename'] = $file->filename; + $project['name'] = $file->name; + cvs_deploy_version_alter($file->info['version'], $project); + $form['version'][$modulename]['#value'] = $file->info['version']; } } }