From 319f5ef91bc07a2a2e1f34ee6dbaada4cad3ca80 Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Sun, 27 Sep 2009 00:15:28 +0000 Subject: [PATCH] - Patch #499828 by Dave Reid, Darren Oh, dww | Dries: fixed wrong release date on multi-module projects. Now with extra tests! --- modules/update/tests/dev-snapshot.xml | 50 +++++++++++++++++++++++++++ modules/update/update.compare.inc | 7 +++- modules/update/update.test | 24 +++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 modules/update/tests/dev-snapshot.xml diff --git a/modules/update/tests/dev-snapshot.xml b/modules/update/tests/dev-snapshot.xml new file mode 100644 index 000000000000..49dcc3f5f62f --- /dev/null +++ b/modules/update/tests/dev-snapshot.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<project xmlns:dc="http://purl.org/dc/elements/1.1/"> +<title>Drupal</title> +<short_name>drupal</short_name> +<dc:creator>Drupal</dc:creator> +<api_version>7.x</api_version> +<recommended_major>7</recommended_major> +<supported_majors>7</supported_majors> +<default_major>7</default_major> +<project_status>published</project_status> +<link>http://example.com/project/drupal</link> + <terms> + <term><name>Projects</name><value>Drupal project</value></term> + </terms> +<releases> + <release> + <name>Drupal 7.0</name> + <version>7.0</version> + <tag>DRUPAL-7-0</tag> + <version_major>7</version_major> + <version_patch>0</version_patch> + <status>published</status> + <release_link>http://example.com/drupal-7-0-release</release_link> + <download_link>http://example.com/drupal-7-0.tar.gz</download_link> + <date>1250424521</date> + <mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash> + <filesize>1073741824</filesize> + <terms> + <term><name>Release type</name><value>New features</value></term> + <term><name>Release type</name><value>Bug fixes</value></term> + </terms> + </release> + <release> + <name>Drupal 7.x-dev</name> + <version>7.x-dev</version> + <tag>DRUPAL-7</tag> + <version_major>7</version_major> + <version_extra>dev</version_extra> + <status>published</status> + <release_link>http://example.com/drupal-7-x-dev-release</release_link> + <download_link>http://example.com/drupal-7.x-dev.tar.gz</download_link> + <date>1250424581</date> + <mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash> + <filesize>2147483648</filesize> + <terms> + <term><name>Release type</name><value>Bug fixes</value></term> + </terms> + </release> +</releases> +</project> diff --git a/modules/update/update.compare.inc b/modules/update/update.compare.inc index e800a161bac9..764c42cba0ee 100644 --- a/modules/update/update.compare.inc +++ b/modules/update/update.compare.inc @@ -117,6 +117,10 @@ function _update_process_info_list(&$projects, $list, $project_type, $status) { $file->info['_info_file_ctime'] = filectime($info_filename); } + if (!isset($file->info['datestamp'])) { + $file->info['datestamp'] = 0; + } + $project_name = $file->info['project']; // Figure out what project type we're going to use to display this module @@ -139,7 +143,7 @@ function _update_process_info_list(&$projects, $list, $project_type, $status) { $projects[$project_name] = array( 'name' => $project_name, 'info' => $file->info, - 'datestamp' => isset($file->info['datestamp']) ? $file->info['datestamp'] : 0, + 'datestamp' => $file->info['datestamp'], 'includes' => array($file->name => $file->info['name']), 'project_type' => $project_display_type, 'project_status' => $status, @@ -153,6 +157,7 @@ function _update_process_info_list(&$projects, $list, $project_type, $status) { // 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']); + $projects[$project_name]['datestamp'] = max($projects[$project_name]['datestamp'], $file->info['datestamp']); } elseif (empty($status)) { // If we have a project_name that matches, but the project_display_type diff --git a/modules/update/update.test b/modules/update/update.test index 3ce325056fb1..79fb9127182c 100644 --- a/modules/update/update.test +++ b/modules/update/update.test @@ -68,6 +68,30 @@ class UpdateTestCase extends DrupalWebTestCase { $this->assertRaw(l(t('Release notes'), 'http://example.com/drupal-7-2-release'), t('Link to release notes appears.')); } + /** + * Ensure proper results where there are date mismatches among modules. + */ + function testDatestampMismatch() { + $system_info = array( + '#all' => array( + // We need to think we're running a -dev snapshot to see dates. + 'version' => '7.0-dev', + 'datestamp' => time(), + ), + 'block' => array( + // This is 2001-09-09 01:46:40 GMT, so test for "2001-Sep-". + 'datestamp' => '1000000000', + ), + ); + variable_set('update_test_system_info', $system_info); + $this->refreshUpdateData('dev-snapshot.xml'); + $this->drupalGet('admin/reports/updates'); + $this->assertNoText(t('2001-Sep-')); + $this->assertText(t('Up to date')); + $this->assertNoText(t('Update available')); + $this->assertNoText(t('Security update required!')); + } + /** * Helper function: force te update cache to refresh based on the contents of * the specified XML file. -- GitLab