summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/common.inc23
-rw-r--r--includes/xmlrpc.inc1
-rw-r--r--modules/aggregator/aggregator.fetcher.inc1
-rw-r--r--modules/openid/openid.module8
-rw-r--r--modules/system/system.install20
-rw-r--r--modules/system/system.module10
-rw-r--r--modules/update/update.fetch.inc1
7 files changed, 24 insertions, 40 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 8de8894e3..6946fa02a 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -459,23 +459,7 @@ function drupal_access_denied() {
function drupal_http_request($url, array $options = array()) {
global $db_prefix;
- static $self_test = FALSE;
$result = new stdClass();
- // Try to clear the drupal_http_request_fails variable if it's set. We
- // can't tie this call to any error because there is no surefire way to
- // tell whether a request has failed, so we add the check to places where
- // some parsing has failed.
- if (!$self_test && variable_get('drupal_http_request_fails', FALSE)) {
- $self_test = TRUE;
- $works = module_invoke('system', 'check_http_request');
- $self_test = FALSE;
- if (!$works) {
- // Do not bother with further operations if we already know that we
- // have no chance.
- $result->error = t("The server can't issue HTTP requests");
- return $result;
- }
- }
// Parse the URL and make sure we can handle the schema.
$uri = @parse_url($url);
@@ -513,6 +497,13 @@ function drupal_http_request($url, array $options = array()) {
// clash with the HTTP status codes.
$result->code = -$errno;
$result->error = trim($errstr);
+
+ // 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/includes/xmlrpc.inc b/includes/xmlrpc.inc
index 4964838ee..7dbb0665b 100644
--- a/includes/xmlrpc.inc
+++ b/includes/xmlrpc.inc
@@ -349,7 +349,6 @@ function xmlrpc_error($code = NULL, $message = NULL) {
$xmlrpc_error->is_error = TRUE;
$xmlrpc_error->code = $code;
$xmlrpc_error->message = $message;
- module_invoke('system', 'check_http_request');
}
return $xmlrpc_error;
}
diff --git a/modules/aggregator/aggregator.fetcher.inc b/modules/aggregator/aggregator.fetcher.inc
index ac91a0dc1..026389815 100644
--- a/modules/aggregator/aggregator.fetcher.inc
+++ b/modules/aggregator/aggregator.fetcher.inc
@@ -76,6 +76,5 @@ function aggregator_aggregator_fetch($feed) {
default:
watchdog('aggregator', 'The feed from %site seems to be broken, due to "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error), WATCHDOG_WARNING);
drupal_set_message(t('The feed from %site seems to be broken, because of error "%error".', array('%site' => $feed->title, '%error' => $result->code . ' ' . $result->error)));
- module_invoke('system', 'check_http_request');
}
}
diff --git a/modules/openid/openid.module b/modules/openid/openid.module
index 26902fe9a..f7636ad29 100644
--- a/modules/openid/openid.module
+++ b/modules/openid/openid.module
@@ -316,9 +316,6 @@ function openid_discovery($claimed_id) {
}
}
}
- if (!$services) {
- module_invoke('system', 'check_http_request');
- }
return $services;
}
@@ -354,13 +351,11 @@ function openid_association($op_endpoint) {
);
$assoc_result = drupal_http_request($op_endpoint, $assoc_options);
if (isset($assoc_result->error)) {
- module_invoke('system', 'check_http_request');
return FALSE;
}
$assoc_response = _openid_parse_message($assoc_result->data);
if (isset($assoc_response['mode']) && $assoc_response['mode'] == 'error') {
- module_invoke('system', 'check_http_request');
return FALSE;
}
@@ -529,8 +524,5 @@ function openid_verify_assertion($op_endpoint, $response) {
}
}
}
- if (!$valid) {
- module_invoke('system', 'check_http_request');
- }
return $valid;
}
diff --git a/modules/system/system.install b/modules/system/system.install
index 5b73c4b87..7e3714aa9 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -256,8 +256,8 @@ function system_requirements($phase) {
include_once DRUPAL_ROOT . '/includes/unicode.inc';
$requirements = array_merge($requirements, unicode_requirements());
- // Check for update status module.
if ($phase == 'runtime') {
+ // Check for update status module.
if (!module_exists('update')) {
$requirements['update status'] = array(
'value' => $t('Not enabled'),
@@ -269,16 +269,18 @@ function system_requirements($phase) {
$requirements['update status'] = array(
'value' => $t('Enabled'),
);
- if (variable_get('drupal_http_request_fails', FALSE)) {
- $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.'),
- );
- }
}
$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;
diff --git a/modules/system/system.module b/modules/system/system.module
index c62b43784..7d5e4e22a 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -2177,12 +2177,14 @@ function system_time_zones($blank = NULL) {
* will contain an error.
*
* @return
- * Whether the www.example.com page can be requested via HTTP.
+ * TRUE if this installation can issue HTTP requests.
*/
function system_check_http_request() {
- $result = drupal_http_request('http://www.example.com');
- // If the resulting page contains RFC 2606 then we got the page we wanted.
- $works = isset($result->data) && preg_match('/RFC\s+2606/', $result->data);
+ // Try to get the content of the front page via drupal_http_request().
+ $result = drupal_http_request(url('', array('absolute' => TRUE)));
+ // 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;
}
diff --git a/modules/update/update.fetch.inc b/modules/update/update.fetch.inc
index 0ffb746d7..adae8c36c 100644
--- a/modules/update/update.fetch.inc
+++ b/modules/update/update.fetch.inc
@@ -56,7 +56,6 @@ function _update_refresh() {
watchdog('update', 'Fetched information about all available new releases and updates.', array(), WATCHDOG_NOTICE, l(t('view'), 'admin/reports/updates'));
}
else {
- module_invoke('system', 'check_http_request');
watchdog('update', 'Unable to fetch any information about available new releases and updates.', array(), WATCHDOG_ERROR, l(t('view'), 'admin/reports/updates'));
}
return $available;