diff --git modules/update/tests/update_test.module modules/update/tests/update_test.module index fb7d3ab..1d0bd61 100644 --- modules/update/tests/update_test.module +++ modules/update/tests/update_test.module @@ -13,6 +13,12 @@ function update_test_menu() { 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); + $items['503-error'] = array( + 'title' => t('503 Service unavailable'), + 'page callback' => 'update_callback_service_unavailable', + 'access callback' => TRUE, + 'type' => MENU_CALLBACK, + ); return $items; } @@ -149,3 +155,11 @@ class UpdateTestFileTransfer { return $form; } } + +/** + * Return an Error 503 (Service unavailable) page. + */ +function update_callback_service_unavailable() { + drupal_add_http_header('Status', '503 Service unavailable'); + print "503 Service Temporarily Unavailable"; +} diff --git modules/update/update.fetch.inc modules/update/update.fetch.inc index b3041cb..3fafd55 100644 --- modules/update/update.fetch.inc +++ modules/update/update.fetch.inc @@ -144,7 +144,7 @@ function _update_process_fetch_task($project) { if (empty($fail[$fetch_url_base]) || $fail[$fetch_url_base] < $max_fetch_attempts) { $xml = drupal_http_request($url); - if (isset($xml->data)) { + if (!isset($xml->error) && isset($xml->data)) { $data = $xml->data; } } diff --git modules/update/update.test modules/update/update.test index a1252dc..e4de648 100644 --- modules/update/update.test +++ modules/update/update.test @@ -31,9 +31,9 @@ class UpdateTestHelper extends DrupalWebTestCase { * * @see update_test_mock_page() */ - protected function refreshUpdateStatus($xml_map) { + protected function refreshUpdateStatus($xml_map, $url = 'update-test') { // Tell update module to fetch from the URL provided by update_test module. - variable_set('update_fetch_url', url('update-test', array('absolute' => TRUE))); + variable_set('update_fetch_url', url($url, array('absolute' => TRUE))); // Save the map for update_test_mock_page() to use. variable_set('update_test_xml_map', $xml_map); // Manually check the update status. @@ -201,6 +201,16 @@ class UpdateCoreTestCase extends UpdateTestHelper { $this->assertNoText(t('There is a security update available for your version of Drupal.')); } + /** + * Tests the update module when the update server returns 503 (Service unavailable) errors. + */ + function testServiceUnavailable() { + $this->refreshUpdateStatus(array(), '503-error'); + // Ensure that no "Warning: SimpleXMLElement..." parse errors are found. + $this->assertNoText('SimpleXMLElement'); + $this->assertUniqueText(t('Failed to get available update data for one project.')); + } + protected function setSystemInfo7_0() { $setting = array( '#all' => array(