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) {
$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');
......
......@@ -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;
}
}
}
......
......@@ -211,6 +211,34 @@ class UpdateTestContribCase extends UpdateTestHelper {
$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.
*/
......
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