summaryrefslogtreecommitdiff
path: root/modules/update
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-10-06 13:36:30 +0000
committerDries Buytaert <dries@buytaert.net>2010-10-06 13:36:30 +0000
commit1680103636c556503187f980f1b5dd4a66a72853 (patch)
tree88f4e4af924e1afa840649910acf5872255abf40 /modules/update
parent25d9c40423705ae5767aa431ea55226fb491bf26 (diff)
downloadbrdo-1680103636c556503187f980f1b5dd4a66a72853.tar.gz
brdo-1680103636c556503187f980f1b5dd4a66a72853.tar.bz2
- Patch #931284 by dww: update status admin UI shouldn't rely on hook_help().
Diffstat (limited to 'modules/update')
-rw-r--r--modules/update/update.module48
-rw-r--r--modules/update/update.test59
2 files changed, 85 insertions, 22 deletions
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 '<p>' . 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.') . '</p>';
- 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 .= '<h3>' . t('About') . '</h3>';
@@ -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('<li>' . 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.'));
+ }
+
}