Issue #965078 by catch, akamustang: Fixed HTTP request checking is unreliable and should be removed in favor of watchdog() calls.

8.0.x
catch 2012-05-28 00:19:58 +09:00
parent a2ee8c1e40
commit 6679cf9b66
5 changed files with 9 additions and 40 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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 <code>$conf[\'drupal_http_request_fails\'] = FALSE;</code> to the bottom of your settings.php file.'),
);
}
}
return $requirements;

View File

@ -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.
*/

View File

@ -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;
}
}