From 1680103636c556503187f980f1b5dd4a66a72853 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 6 Oct 2010 13:36:30 +0000 Subject: - Patch #931284 by dww: update status admin UI shouldn't rely on hook_help(). --- modules/update/update.module | 48 ++++++++++++++++++----------------- modules/update/update.test | 59 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 22 deletions(-) (limited to 'modules/update') diff --git a/modules/update/update.module b/modules/update/update.module index 4f1045b7c..ee0e91358 100644 --- a/modules/update/update.module +++ b/modules/update/update.module @@ -79,18 +79,6 @@ function update_help($path, $arg) { case 'admin/reports/updates': return '

' . t('Here you can find information about available updates for your installed modules and themes. Note that each module or theme is part of a "project", which may or may not have the same name, and might include multiple modules or themes within it.') . '

'; - case 'admin/appearance/update': - case 'admin/appearance/install': - case 'admin/modules/update': - case 'admin/modules/install': - case 'admin/reports/updates/update': - case 'admin/reports/updates/install': - case 'admin/reports/updates/settings': - case 'admin/reports/status': - case 'admin/update/ready': - // These pages don't need additional nagging. - break; - case 'admin/help#update': $output = ''; $output .= '

' . t('About') . '

'; @@ -120,14 +108,33 @@ function update_help($path, $arg) { */ function update_init() { if (arg(0) == 'admin' && user_access('administer site configuration')) { + switch ($_GET['q']) { + // These pages don't need additional nagging. + case 'admin/appearance/update': + case 'admin/appearance/install': + case 'admin/modules/update': + case 'admin/modules/install': + case 'admin/reports/updates': + case 'admin/reports/updates/update': + case 'admin/reports/updates/install': + case 'admin/reports/updates/settings': + case 'admin/reports/status': + case 'admin/update/ready': + return; + + // If we are on the appearance or modules list, display a detailed report + // of the update status. + case 'admin/appearance': + case 'admin/modules': + $verbose = TRUE; + break; + + } module_load_install('update'); $status = update_requirements('runtime'); - - // If we are on the appearance or modules list, display a detailed report - // of the update status. - if (arg(1) == 'appearance' || arg(1) == 'modules') { - foreach (array('core', 'contrib') as $report_type) { - $type = 'update_' . $report_type; + foreach (array('core', 'contrib') as $report_type) { + $type = 'update_' . $report_type; + if (!empty($verbose)) { if (isset($status[$type]['severity'])) { if ($status[$type]['severity'] == REQUIREMENT_ERROR) { drupal_set_message($status[$type]['description'], 'error'); @@ -137,12 +144,9 @@ function update_init() { } } } - } - else { // Otherwise, if we're on *any* admin page and there's a security // update missing, print an error message about it. - foreach (array('core', 'contrib') as $report_type) { - $type = 'update_' . $report_type; + else { if (isset($status[$type]) && isset($status[$type]['reason']) && $status[$type]['reason'] === UPDATE_NOT_SECURE) { diff --git a/modules/update/update.test b/modules/update/update.test index fcf4ea91c..6eb0cd795 100644 --- a/modules/update/update.test +++ b/modules/update/update.test @@ -181,6 +181,24 @@ class UpdateCoreTestCase extends UpdateTestHelper { $this->assertText(t('Checked available update data for one project.')); $this->assertNoText(t('There are updates available for your version of Drupal.')); $this->assertText(t('There is a security update available for your version of Drupal.')); + + // Make sure admin/appearance warns you you're missing a security update. + $this->drupalGet('admin/appearance'); + $this->assertNoText(t('There are updates available for your version of Drupal.')); + $this->assertText(t('There is a security update available for your version of Drupal.')); + + // Make sure duplicate messages don't appear on Update status pages. + $this->drupalGet('admin/reports/status'); + // We're expecting "There is a security update..." inside the status report + // itself, but the drupal_set_message() appears as an li so we can prefix + // with that and search for the raw HTML. + $this->assertNoRaw('
  • ' . t('There is a security update available for your version of Drupal.')); + + $this->drupalGet('admin/reports/updates'); + $this->assertNoText(t('There is a security update available for your version of Drupal.')); + + $this->drupalGet('admin/reports/updates/settings'); + $this->assertNoText(t('There is a security update available for your version of Drupal.')); } protected function setSystemInfo7_0() { @@ -604,4 +622,45 @@ class UpdateTestUploadCase extends UpdateTestHelper { // Make sure it didn't clobber the first option from core. $this->assertPattern('/archive extensions are supported:.*zip/', t("Found 'zip' extension")); } + + /** + * Check the messages on Update manager pages when missing a security update. + */ + function testUpdateManagerCoreSecurityUpdateMessages() { + $setting = array( + '#all' => array( + 'version' => '7.0', + ), + ); + variable_set('update_test_system_info', $setting); + variable_set('update_fetch_url', url('update-test', array('absolute' => TRUE))); + variable_set('update_test_xml_map', array('drupal' => '2-sec')); + // Initialize the update status. + $this->drupalGet('admin/reports/updates'); + + // Now, make sure none of the Update manager pages have duplicate messages + // about core missing a security update. + + $this->drupalGet('admin/modules/install'); + $this->assertNoText(t('There is a security update available for your version of Drupal.')); + + $this->drupalGet('admin/modules/update'); + $this->assertNoText(t('There is a security update available for your version of Drupal.')); + + $this->drupalGet('admin/appearance/install'); + $this->assertNoText(t('There is a security update available for your version of Drupal.')); + + $this->drupalGet('admin/appearance/update'); + $this->assertNoText(t('There is a security update available for your version of Drupal.')); + + $this->drupalGet('admin/reports/updates/install'); + $this->assertNoText(t('There is a security update available for your version of Drupal.')); + + $this->drupalGet('admin/reports/updates/update'); + $this->assertNoText(t('There is a security update available for your version of Drupal.')); + + $this->drupalGet('admin/update/ready'); + $this->assertNoText(t('There is a security update available for your version of Drupal.')); + } + } -- cgit v1.2.3