From 6679cf9b66a9767a9b7d40d0fa28163e5293258b Mon Sep 17 00:00:00 2001 From: catch Date: Mon, 28 May 2012 00:19:58 +0900 Subject: [PATCH] Issue #965078 by catch, akamustang: Fixed HTTP request checking is unreliable and should be removed in favor of watchdog() calls. --- core/includes/common.inc | 7 ------- core/modules/aggregator/aggregator.admin.inc | 3 +++ core/modules/system/system.install | 10 ---------- core/modules/system/system.module | 20 -------------------- core/modules/update/update.fetch.inc | 9 ++++++--- 5 files changed, 9 insertions(+), 40 deletions(-) diff --git a/core/includes/common.inc b/core/includes/common.inc index b45819cec9a1..a08cafc1201c 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -828,13 +828,6 @@ function drupal_http_request($url, array $options = array()) { // clash with the HTTP status codes. $result->code = -$errno; $result->error = trim($errstr) ? trim($errstr) : t('Error opening socket @socket', array('@socket' => $socket)); - - // Mark that this request failed. This will trigger a check of the web - // server's ability to make outgoing HTTP requests the next time that - // requirements checking is performed. - // See system_requirements(). - variable_set('drupal_http_request_fails', TRUE); - return $result; } diff --git a/core/modules/aggregator/aggregator.admin.inc b/core/modules/aggregator/aggregator.admin.inc index 09da1cf68109..9e5546fee335 100644 --- a/core/modules/aggregator/aggregator.admin.inc +++ b/core/modules/aggregator/aggregator.admin.inc @@ -323,6 +323,9 @@ function aggregator_form_opml_submit($form, &$form_state) { if (!isset($response->error)) { $data = $response->data; } + else { + watchdog('aggregator', 'HTTP request to @url failed with error: @error', array('@url' => $form_state['values']['remote'], '@error' => $response->error)); + } } $feeds = _aggregator_parse_opml($data); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index f967bb677e3a..5581d01af1c8 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -487,16 +487,6 @@ function system_requirements($phase) { ); } $requirements['update status']['title'] = $t('Update notifications'); - - // Check that Drupal can issue HTTP requests. - if (variable_get('drupal_http_request_fails', TRUE) && !system_check_http_request()) { - $requirements['http requests'] = array( - 'title' => $t('HTTP request status'), - 'value' => $t('Fails'), - 'severity' => REQUIREMENT_ERROR, - 'description' => $t('Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality. This could be due to your webserver configuration or PHP settings, and should be resolved in order to download information about available updates, fetch aggregator feeds, sign in via OpenID, or use other network-dependent services. If you are certain that Drupal can access web pages but you are still seeing this message, you may add $conf[\'drupal_http_request_fails\'] = FALSE; to the bottom of your settings.php file.'), - ); - } } return $requirements; diff --git a/core/modules/system/system.module b/core/modules/system/system.module index ebc5dcffa5c6..6e60da898cec 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -3409,26 +3409,6 @@ function system_time_zones($blank = NULL) { return $zones; } -/** - * Checks whether the server is capable of issuing HTTP requests. - * - * The function sets the drupal_http_request_fail system variable to TRUE if - * drupal_http_request() does not work and then the system status report page - * will contain an error. - * - * @return - * TRUE if this installation can issue HTTP requests. - */ -function system_check_http_request() { - // Try to get the content of the front page via drupal_http_request(). - $result = drupal_http_request(url('', array('absolute' => TRUE)), array('max_redirects' => 0)); - // We only care that we get a http response - this means that Drupal - // can make a http request. - $works = isset($result->code) && ($result->code >= 100) && ($result->code < 600); - variable_set('drupal_http_request_fails', !$works); - return $works; -} - /** * Menu callback; Retrieve a JSON object containing a suggested time zone name. */ diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc index 6de781d6a3fb..c6652a7075fe 100644 --- a/core/modules/update/update.fetch.inc +++ b/core/modules/update/update.fetch.inc @@ -142,9 +142,12 @@ function _update_process_fetch_task($project) { $project_name = $project['name']; if (empty($fail[$fetch_url_base]) || $fail[$fetch_url_base] < $max_fetch_attempts) { - $xml = drupal_http_request($url); - if (!isset($xml->error) && isset($xml->data)) { - $data = $xml->data; + $result = drupal_http_request($url); + if (isset($result->error)) { + watchdog('update', 'HTTP request to @url failed with error: @error.', array('@url' => $url, '@error' => $result->error)); + } + elseif (!isset($result->error) && isset($result->data)) { + $data = $result->data; } }