diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-13 08:02:49 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-13 08:02:49 +0000 |
commit | bc9a742f68a02e69a51aa5aa0b6544294697f433 (patch) | |
tree | fe706bbc17ad1ee431cc20775dd10758605b2510 /modules/update | |
parent | b4d3bdbf38001197243d4dc7f4046cf3d98dab60 (diff) | |
download | brdo-bc9a742f68a02e69a51aa5aa0b6544294697f433.tar.gz brdo-bc9a742f68a02e69a51aa5aa0b6544294697f433.tar.bz2 |
#597390 by Dave Reid and dww: Fixed PHP notices on non-existant projects when parsing update XML.
Diffstat (limited to 'modules/update')
-rw-r--r-- | modules/update/tests/aaa_update_test.no-releases.xml | 2 | ||||
-rw-r--r-- | modules/update/tests/update_test.module | 7 | ||||
-rw-r--r-- | modules/update/update.fetch.inc | 30 | ||||
-rw-r--r-- | modules/update/update.test | 28 |
4 files changed, 54 insertions, 13 deletions
diff --git a/modules/update/tests/aaa_update_test.no-releases.xml b/modules/update/tests/aaa_update_test.no-releases.xml new file mode 100644 index 000000000..e266d4992 --- /dev/null +++ b/modules/update/tests/aaa_update_test.no-releases.xml @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="utf-8"?> +<error>No release history was found for the requested project (aaa_update_test).</error> diff --git a/modules/update/tests/update_test.module b/modules/update/tests/update_test.module index f95a5cb9a..4ae4bccf9 100644 --- a/modules/update/tests/update_test.module +++ b/modules/update/tests/update_test.module @@ -62,7 +62,12 @@ function update_test_mock_page($project_name) { $availability_scenario = $xml_map['#all']; } else { - return FALSE; + // The test didn't specify (for example, the webroot has other modules and + // themes installed but they're disabled by the version of the site + // running the test. So, we default to a file we know won't exist, so at + // least we'll get an empty page from readfile instead of a bunch of + // Drupal page output. + $availability_scenario = '#broken#'; } $path = drupal_get_path('module', 'update_test'); diff --git a/modules/update/update.fetch.inc b/modules/update/update.fetch.inc index df1526cd6..a7a344813 100644 --- a/modules/update/update.fetch.inc +++ b/modules/update/update.fetch.inc @@ -357,25 +357,31 @@ function update_parse_xml($raw_xml) { // were detected. Catch any exception and return failure (NULL). return; } + // If there is no valid project data, the XML is invalid, so return failure. + if (!isset($xml->short_name)) { + return; + } $short_name = (string)$xml->short_name; $data = array(); foreach ($xml as $k => $v) { $data[$k] = (string)$v; } $data['releases'] = array(); - foreach ($xml->releases->children() as $release) { - $version = (string)$release->version; - $data['releases'][$version] = array(); - foreach ($release->children() as $k => $v) { - $data['releases'][$version][$k] = (string)$v; - } - $data['releases'][$version]['terms'] = array(); - if ($release->terms) { - foreach ($release->terms->children() as $term) { - if (!isset($data['releases'][$version]['terms'][(string)$term->name])) { - $data['releases'][$version]['terms'][(string)$term->name] = array(); + if (isset($xml->releases)) { + foreach ($xml->releases->children() as $release) { + $version = (string)$release->version; + $data['releases'][$version] = array(); + foreach ($release->children() as $k => $v) { + $data['releases'][$version][$k] = (string)$v; + } + $data['releases'][$version]['terms'] = array(); + if ($release->terms) { + foreach ($release->terms->children() as $term) { + if (!isset($data['releases'][$version]['terms'][(string)$term->name])) { + $data['releases'][$version]['terms'][(string)$term->name] = array(); + } + $data['releases'][$version]['terms'][(string)$term->name][] = (string)$term->value; } - $data['releases'][$version]['terms'][(string)$term->name][] = (string)$term->value; } } } diff --git a/modules/update/update.test b/modules/update/update.test index 220c81494..dd07b5723 100644 --- a/modules/update/update.test +++ b/modules/update/update.test @@ -212,6 +212,34 @@ class UpdateTestContribCase extends UpdateTestHelper { } /** + * Tests when there is no available release data for a contrib module. + */ + function testNoReleasesAvailable() { + $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); + $this->refreshUpdateStatus(array('drupal' => '0', 'aaa_update_test' => 'no-releases')); + $this->drupalGet('admin/reports/updates'); + // Cannot use $this->standardTests() because we need to check for the + // 'No available releases found' string. + $this->assertRaw('<h3>' . t('Drupal core') . '</h3>'); + $this->assertRaw(l(t('Drupal'), 'http://example.com/project/drupal')); + $this->assertText(t('Up to date')); + $this->assertRaw('<h3>' . t('Modules') . '</h3>'); + $this->assertNoText(t('Update available')); + $this->assertText(t('No available releases found')); + $this->assertNoRaw(l(t('AAA Update test'), 'http://example.com/project/aaa_update_test')); + } + + /** * Test the basic functionality of a contrib module on the status report. */ function testUpdateContribBasic() { |