Commit bc9a742f authored by webchick's avatar webchick
Browse files

#597390 by Dave Reid and dww: Fixed PHP notices on non-existant projects when parsing update XML.

parent b4d3bdbf
<?xml version="1.0" encoding="utf-8"?>
<error>No release history was found for the requested project (aaa_update_test).</error>
...@@ -62,7 +62,12 @@ function update_test_mock_page($project_name) { ...@@ -62,7 +62,12 @@ function update_test_mock_page($project_name) {
$availability_scenario = $xml_map['#all']; $availability_scenario = $xml_map['#all'];
} }
else { 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'); $path = drupal_get_path('module', 'update_test');
......
...@@ -357,25 +357,31 @@ function update_parse_xml($raw_xml) { ...@@ -357,25 +357,31 @@ function update_parse_xml($raw_xml) {
// were detected. Catch any exception and return failure (NULL). // were detected. Catch any exception and return failure (NULL).
return; 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; $short_name = (string)$xml->short_name;
$data = array(); $data = array();
foreach ($xml as $k => $v) { foreach ($xml as $k => $v) {
$data[$k] = (string)$v; $data[$k] = (string)$v;
} }
$data['releases'] = array(); $data['releases'] = array();
foreach ($xml->releases->children() as $release) { if (isset($xml->releases)) {
$version = (string)$release->version; foreach ($xml->releases->children() as $release) {
$data['releases'][$version] = array(); $version = (string)$release->version;
foreach ($release->children() as $k => $v) { $data['releases'][$version] = array();
$data['releases'][$version][$k] = (string)$v; foreach ($release->children() as $k => $v) {
} $data['releases'][$version][$k] = (string)$v;
$data['releases'][$version]['terms'] = array(); }
if ($release->terms) { $data['releases'][$version]['terms'] = array();
foreach ($release->terms->children() as $term) { if ($release->terms) {
if (!isset($data['releases'][$version]['terms'][(string)$term->name])) { foreach ($release->terms->children() as $term) {
$data['releases'][$version]['terms'][(string)$term->name] = array(); 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;
} }
} }
} }
......
...@@ -211,6 +211,34 @@ class UpdateTestContribCase extends UpdateTestHelper { ...@@ -211,6 +211,34 @@ class UpdateTestContribCase extends UpdateTestHelper {
$this->drupalLogin($admin_user); $this->drupalLogin($admin_user);
} }
/**
* 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. * Test the basic functionality of a contrib module on the status report.
*/ */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment