cvs diff: Diffing modules/update
Index: modules/update/update.compare.inc
===================================================================
RCS file: /Users/wright/drupal/local_repo/drupal/modules/update/update.compare.inc,v
retrieving revision 1.32
diff -u -p -r1.32 update.compare.inc
--- modules/update/update.compare.inc	6 Oct 2009 01:38:55 -0000	1.32
+++ modules/update/update.compare.inc	6 Oct 2009 16:43:38 -0000
@@ -81,7 +81,24 @@ function update_get_projects() {
  */
 function _update_process_info_list(&$projects, $list, $project_type, $status) {
   foreach ($list as $file) {
-    if ($file->status != $status) {
+    // 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)) {
+      foreach ($file->sub_themes as $key => $name) {
+        // Build a list of enabled sub-themes.
+        if ($list[$key]->status) {
+          $file->enabled_sub_themes[$key] = $name;
+        }
+      }
+      // If there are no enabled subthemes, we should ignore this base theme
+      // for the enabled case. If the site is trying to display disabled
+      // themes, we'll catch it then.
+      if (empty($file->enabled_sub_themes)) {
+        continue;
+      }
+    }
+    // Otherwise, just add projects of the proper status to our list.
+    elseif ($file->status != $status) {
       continue;
     }
 
@@ -133,10 +150,25 @@ function _update_process_info_list(&$pro
     else {
       $project_display_type = $project_type;
     }
-    if (empty($status)) {
+    if (empty($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.
       $project_display_type .= '-disabled';
     }
+    // Add a list of sub-themes that "depend on" the project and a list of base
+    // themes that are "required by" the project.
+    if ($project_name == 'drupal') {
+      // Drupal core is always required, so this extra info would be noise.
+      $sub_themes = array();
+      $base_themes = array();
+    }
+    else {
+      // Add list of enabled sub-themes.
+      $sub_themes = !empty($file->enabled_sub_themes) ? $file->enabled_sub_themes : array();
+      // 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.
@@ -147,6 +179,8 @@ function _update_process_info_list(&$pro
         'includes' => array($file->name => $file->info['name']),
         'project_type' => $project_display_type,
         'project_status' => $status,
+        'sub_themes' => $sub_themes,
+        'base_themes' => $base_themes,
       );
     }
     elseif ($projects[$project_name]['project_type'] == $project_display_type) {
@@ -158,6 +192,8 @@ function _update_process_info_list(&$pro
       $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']);
+      $projects[$project_name]['sub_themes'] = array_merge($projects[$project_name]['sub_themes'], $sub_themes);
+      $projects[$project_name]['base_themes'] = array_merge($projects[$project_name]['base_themes'], $base_themes);
     }
     elseif (empty($status)) {
       // If we have a project_name that matches, but the project_display_type
Index: modules/update/update.report.inc
===================================================================
RCS file: /Users/wright/drupal/local_repo/drupal/modules/update/update.report.inc,v
retrieving revision 1.22
diff -u -p -r1.22 update.report.inc
--- modules/update/update.report.inc	5 Oct 2009 02:26:36 -0000	1.22
+++ modules/update/update.report.inc	6 Oct 2009 16:11:28 -0000
@@ -194,6 +194,20 @@ function theme_update_report($data) {
     }
     $row .= "</div>\n";
 
+    if (!empty($project['base_themes'])) {
+      $row .= '<div class="basethemes">';
+      sort($project['base_themes']);
+      $row .= t('Depends on: %basethemes', array('%basethemes' => implode(', ', $project['base_themes'])));
+      $row .= "</div>\n";
+    }
+
+    if (!empty($project['sub_themes'])) {
+      $row .= '<div class="subthemes">';
+      sort($project['sub_themes']);
+      $row .= t('Required by: %subthemes', array('%subthemes' => implode(', ', $project['sub_themes'])));
+      $row .= "</div>\n";
+    }
+
     $row .= "</div>\n"; // info div.
 
     if (!isset($rows[$project['project_type']])) {
Index: modules/update/update.test
===================================================================
RCS file: /Users/wright/drupal/local_repo/drupal/modules/update/update.test,v
retrieving revision 1.4
diff -u -p -r1.4 update.test
--- modules/update/update.test	5 Oct 2009 02:26:36 -0000	1.4
+++ modules/update/update.test	6 Oct 2009 16:44:35 -0000
@@ -266,5 +266,104 @@ class UpdateTestContribCase extends Upda
     $this->assertTrue(strpos($this->drupalGetContent(), $bbb_project_link) < strpos($this->drupalGetContent(), $ccc_project_link), "'BBB Update test' project is listed before the 'CCC Update test' project");
   }
 
+  /**
+   * Test that subthemes are notified about security updates for base themes.
+   */
+  function testUpdateBaseThemeSecurityUpdate() {
+    // Only enable the subtheme, not the base theme.
+    db_update('system')
+      ->fields(array('status' => 1))
+      ->condition('type', 'theme')
+      ->condition('name', 'update_test_subtheme')
+      ->execute();
+
+    // Define the initial state for core and the subtheme.
+    $system_info = array(
+      // We want core to be version 7.0.    
+      '#all' => array(
+        'version' => '7.0',
+      ),
+      // Show the update_test_basetheme
+      'update_test_basetheme' => array(
+        'project' => 'update_test_basetheme',
+        'version' => '7.x-1.0',
+        'hidden' => FALSE,
+      ),
+      // Show the update_test_subtheme
+      'update_test_subtheme' => array(
+        'project' => 'update_test_subtheme',
+        'version' => '7.x-1.0',
+        'hidden' => FALSE,
+      ),
+    );
+    variable_set('update_test_system_info', $system_info);
+    $xml_mapping = array(
+      'drupal' => '0',
+      'update_test_subtheme' => '1_0',
+      'update_test_basetheme' => '1_1-sec',
+    );
+    $this->refreshUpdateStatus($xml_mapping);
+    $this->drupalGet('admin/reports/updates');
+    $this->assertText(t('Security update required!'));
+    $this->assertRaw(l(t('Update test base theme'), 'http://example.com/project/update_test_basetheme'), t('Link to the Update test base theme project appears.'));
+  }
+
+  /**
+   * Test that disabled themes are only shown when desired.
+   */
+  function testUpdateShowDisabledThemes() {
+    // Make sure all the update_test_* themes are disabled.
+    db_update('system')
+      ->fields(array('status' => 0))
+      ->condition('type', 'theme')
+      ->condition('name', 'update_test_%', 'LIKE')
+      ->execute();
+
+    // Define the initial state for core and the test contrib themes.
+    $system_info = array(
+      // We want core to be version 7.0.    
+      '#all' => array(
+        'version' => '7.0',
+      ),
+      // The update_test_basetheme should be visible and up to date.
+      'update_test_basetheme' => array(
+        'project' => 'update_test_basetheme',
+        'version' => '7.x-1.1',
+        'hidden' => FALSE,
+      ),
+      // The update_test_subtheme should be visible and up to date.
+      'update_test_subtheme' => array(
+        'project' => 'update_test_subtheme',
+        'version' => '7.x-1.0',
+        'hidden' => FALSE,
+      ),
+    );
+    variable_set('update_test_system_info', $system_info);
+    $xml_mapping = array(
+      'drupal' => '0',
+      'update_test_subtheme' => '1_0',
+      'update_test_basetheme' => '1_1-sec',
+    );
+    $base_theme_project_link = l(t('Update test base theme'), 'http://example.com/project/update_test_basetheme');
+    $sub_theme_project_link = l(t('Update test subtheme'), 'http://example.com/project/update_test_subtheme');
+    foreach (array(TRUE, FALSE) as $check_disabled) {
+      variable_set('update_check_disabled', $check_disabled);
+      $this->refreshUpdateStatus($xml_mapping);
+      $this->drupalGet('admin/reports/updates');
+      // In neither case should we see the "Themes" heading for enabled themes.
+      $this->assertNoText(t('Themes'));
+      if ($check_disabled) {
+        $this->assertText(t('Disabled themes'));
+        $this->assertRaw($base_theme_project_link, t('Link to the Update test base theme project appears.'));
+        $this->assertRaw($sub_theme_project_link, t('Link to the Update test subtheme project appears.'));
+      }
+      else {
+        $this->assertNoText(t('Disabled themes'));
+        $this->assertNoRaw($base_theme_project_link, t('Link to the Update test base theme project does not appear.'));
+        $this->assertNoRaw($sub_theme_project_link, t('Link to the Update test subtheme project does not appear.'));
+      }
+    }
+  }
+
 }
 
cvs diff: Diffing modules/update/tests
Index: modules/update/tests/update_test_basetheme.1_1-sec.xml
===================================================================
RCS file: modules/update/tests/update_test_basetheme.1_1-sec.xml
diff -N modules/update/tests/update_test_basetheme.1_1-sec.xml
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/update/tests/update_test_basetheme.1_1-sec.xml	6 Oct 2009 16:11:28 -0000
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project xmlns:dc="http://purl.org/dc/elements/1.1/">
+<title>Update test base theme</title>
+<short_name>update_test_basetheme</short_name>
+<dc:creator>Drupal</dc:creator>
+<api_version>7.x</api_version>
+<recommended_major>1</recommended_major>
+<supported_majors>1</supported_majors>
+<default_major>1</default_major>
+<project_status>published</project_status>
+<link>http://example.com/project/update_test_basetheme</link>
+  <terms>
+   <term><name>Projects</name><value>Themes</value></term>
+  </terms>
+<releases>
+ <release>
+  <name>update_test_basetheme 7.x-1.1</name>
+  <version>7.x-1.1</version>
+  <tag>DRUPAL-7--1-1</tag>
+  <version_major>1</version_major>
+  <version_patch>1</version_patch>
+  <status>published</status>
+  <release_link>http://example.com/update_test_basetheme-7-x-1-1-release</release_link>
+  <download_link>http://example.com/update_test_basetheme-7.x-1.1.tar.gz</download_link>
+  <date>1250624521</date>
+  <mdhash>b966255555d9c9b86d480ca08cfaa98e</mdhash>
+  <filesize>1073763241</filesize>
+  <terms>
+   <term><name>Release type</name><value>Security update</value></term>
+   <term><name>Release type</name><value>New features</value></term>
+   <term><name>Release type</name><value>Bug fixes</value></term>
+  </terms>
+ </release>
+ <release>
+  <name>update_test_basetheme 7.x-1.0</name>
+  <version>7.x-1.0</version>
+  <tag>DRUPAL-7--1-0</tag>
+  <version_major>1</version_major>
+  <version_patch>0</version_patch>
+  <status>published</status>
+  <release_link>http://example.com/update_test_basetheme-7-x-1-0-release</release_link>
+  <download_link>http://example.com/update_test_basetheme-7.x-1.0.tar.gz</download_link>
+  <date>1250524521</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>
+</releases>
+</project>
Index: modules/update/tests/update_test_subtheme.1_0.xml
===================================================================
RCS file: modules/update/tests/update_test_subtheme.1_0.xml
diff -N modules/update/tests/update_test_subtheme.1_0.xml
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/update/tests/update_test_subtheme.1_0.xml	6 Oct 2009 16:11:28 -0000
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project xmlns:dc="http://purl.org/dc/elements/1.1/">
+<title>Update test subtheme</title>
+<short_name>update_test_subtheme</short_name>
+<dc:creator>Drupal</dc:creator>
+<api_version>7.x</api_version>
+<recommended_major>1</recommended_major>
+<supported_majors>1</supported_majors>
+<default_major>1</default_major>
+<project_status>published</project_status>
+<link>http://example.com/project/update_test_subtheme</link>
+  <terms>
+   <term><name>Projects</name><value>Themes</value></term>
+  </terms>
+<releases>
+ <release>
+  <name>update_test_subtheme 7.x-1.0</name>
+  <version>7.x-1.0</version>
+  <tag>DRUPAL-7--1-0</tag>
+  <version_major>1</version_major>
+  <version_patch>0</version_patch>
+  <status>published</status>
+  <release_link>http://example.com/update_test_subtheme-7-x-1-0-release</release_link>
+  <download_link>http://example.com/update_test_subtheme-7.x-1.0.tar.gz</download_link>
+  <date>1250524521</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>
+</releases>
+</project>
cvs diff: Diffing themes/tests
cvs diff: Diffing themes/tests/update_test_basetheme
Index: themes/tests/update_test_basetheme/update_test_basetheme.info
===================================================================
RCS file: themes/tests/update_test_basetheme/update_test_basetheme.info
diff -N themes/tests/update_test_basetheme/update_test_basetheme.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ themes/tests/update_test_basetheme/update_test_basetheme.info	6 Oct 2009 16:11:28 -0000
@@ -0,0 +1,6 @@
+; $Id$
+name = Update test base theme
+description = Test theme which acts as a base theme for other test subthemes.
+core = 7.x
+engine = phptemplate
+hidden = TRUE
cvs diff: Diffing themes/tests/update_test_subtheme
Index: themes/tests/update_test_subtheme/update_test_subtheme.info
===================================================================
RCS file: themes/tests/update_test_subtheme/update_test_subtheme.info
diff -N themes/tests/update_test_subtheme/update_test_subtheme.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ themes/tests/update_test_subtheme/update_test_subtheme.info	6 Oct 2009 16:11:28 -0000
@@ -0,0 +1,7 @@
+; $Id$
+name = Update test subtheme
+description = Test theme which uses update_test_basetheme as the base theme.
+core = 7.x
+engine = phptemplate
+base theme = update_test_basetheme
+hidden = TRUE
