summaryrefslogtreecommitdiff
path: root/modules/update
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-10-04 07:26:25 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-10-04 07:26:25 +0000
commit28d47535988600fd8516424b38a4bbb9a0316ad6 (patch)
treed10b555e08f12bfcc410898c4992b55faa7aec45 /modules/update
parentad19ce7a0b8bf580098a74ce32693f3e117bd6b3 (diff)
downloadbrdo-28d47535988600fd8516424b38a4bbb9a0316ad6.tar.gz
brdo-28d47535988600fd8516424b38a4bbb9a0316ad6.tar.bz2
#929756 by dww: Fixed Update manager UI uses stale project data.
Diffstat (limited to 'modules/update')
-rw-r--r--modules/update/tests/update_test.module26
-rw-r--r--modules/update/update.compare.inc14
-rw-r--r--modules/update/update.test61
3 files changed, 99 insertions, 2 deletions
diff --git a/modules/update/tests/update_test.module b/modules/update/tests/update_test.module
index 252edb361..34608363a 100644
--- a/modules/update/tests/update_test.module
+++ b/modules/update/tests/update_test.module
@@ -40,6 +40,32 @@ function update_test_system_info_alter(&$info, $file) {
}
/**
+ * Implements hook_update_status_alter().
+ *
+ * This checks the 'update_test_update_status' variable and sees if we need to
+ * alter the update status for the given project based on the setting. The
+ * setting is expected to be a nested associative array. If the key '#all' is
+ * defined, its subarray will include .info keys and values for all modules
+ * and themes on the system. Otherwise, the settings array is keyed by the
+ * module or theme short name and the subarrays contain settings just for that
+ * module or theme.
+ */
+function update_test_update_status_alter(&$projects) {
+ $setting = variable_get('update_test_update_status', array());
+ if (!empty($setting)) {
+ foreach ($projects as $project_name => &$project) {
+ foreach (array('#all', $project_name) as $id) {
+ if (!empty($setting[$id])) {
+ foreach ($setting[$id] as $key => $value) {
+ $project[$key] = $value;
+ }
+ }
+ }
+ }
+ }
+}
+
+/**
* Page callback, prints mock XML for the update module.
*
* The specific XML file to print depends on two things: the project we're
diff --git a/modules/update/update.compare.inc b/modules/update/update.compare.inc
index 1dd0ba586..a4dc6ceec 100644
--- a/modules/update/update.compare.inc
+++ b/modules/update/update.compare.inc
@@ -738,10 +738,20 @@ function update_calculate_project_update_status($project, &$project_data, $avail
function update_project_cache($cid) {
$projects = array();
- // On certain paths, we should clear the cache and recompute the projects or
+ // On certain paths, we should clear the cache and recompute the projects for
// update status of the site to avoid presenting stale information.
$q = $_GET['q'];
- $paths = array('admin/modules', 'admin/appearance', 'admin/reports', 'admin/reports/updates', 'admin/reports/status', 'admin/reports/updates/check');
+ $paths = array(
+ 'admin/modules',
+ 'admin/modules/update',
+ 'admin/appearance',
+ 'admin/appearance/update',
+ 'admin/reports',
+ 'admin/reports/updates',
+ 'admin/reports/updates/update',
+ 'admin/reports/status',
+ 'admin/reports/updates/check',
+ );
if (in_array($q, $paths)) {
_update_cache_clear($cid);
}
diff --git a/modules/update/update.test b/modules/update/update.test
index 66f7907fe..2b6d84dcc 100644
--- a/modules/update/update.test
+++ b/modules/update/update.test
@@ -491,6 +491,67 @@ class UpdateTestContribCase extends UpdateTestHelper {
$this->assertRaw(l(t('CCC Update test'), 'http://example.com/project/ccc_update_test'), t('Link to bbb_update_test project appears.'));
}
+ /**
+ * Check that hook_update_status_alter() works to change a status.
+ *
+ * We provide the same external data as if aaa_update_test 7.x-1.0 were
+ * installed and that was the latest release. Then we use
+ * hook_update_status_alter() to try to mark this as missing a security
+ * update, then assert if we see the appropriate warnings on the right
+ * pages.
+ */
+ function testHookUpdateStatusAlter() {
+ variable_set('allow_authorize_operations', TRUE);
+ $update_admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer software updates'));
+ $this->drupalLogin($update_admin_user);
+
+ $system_info = array(
+ '#all' => array(
+ 'version' => '7.0',
+ ),
+ 'aaa_update_test' => array(
+ 'project' => 'aaa_update_test',
+ 'version' => '7.x-1.0',
+ 'hidden' => FALSE,
+ ),
+ );
+ variable_set('update_test_system_info', $system_info);
+ $update_status = array(
+ 'aaa_update_test' => array(
+ 'status' => UPDATE_NOT_SECURE,
+ ),
+ );
+ variable_set('update_test_update_status', $update_status);
+ $this->refreshUpdateStatus(
+ array(
+ 'drupal' => '0',
+ 'aaa_update_test' => '1_0',
+ )
+ );
+ $this->drupalGet('admin/reports/updates');
+ $this->assertRaw('<h3>' . t('Modules') . '</h3>');
+ $this->assertText(t('Security update required!'));
+ $this->assertRaw(l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), t('Link to aaa_update_test project appears.'));
+
+ // Visit the reports page again without the altering and make sure the
+ // status is back to normal.
+ variable_set('update_test_update_status', array());
+ $this->drupalGet('admin/reports/updates');
+ $this->assertRaw('<h3>' . t('Modules') . '</h3>');
+ $this->assertNoText(t('Security update required!'));
+ $this->assertRaw(l(t('AAA Update test'), 'http://example.com/project/aaa_update_test'), t('Link to aaa_update_test project appears.'));
+
+ // Turn the altering back on and visit the Update manager UI.
+ variable_set('update_test_update_status', $update_status);
+ $this->drupalGet('admin/modules/update');
+ $this->assertText(t('Security update'));
+
+ // Turn the altering back off and visit the Update manager UI.
+ variable_set('update_test_update_status', array());
+ $this->drupalGet('admin/modules/update');
+ $this->assertNoText(t('Security update'));
+ }
+
}
class UpdateTestUploadCase extends UpdateTestHelper {