mirror of
git://develop.git.wordpress.org/
synced 2025-01-19 05:38:07 +01:00
Disable fsockopen for 12 hours if it fails. Props jacobsantos, fixes #7514
git-svn-id: https://develop.svn.wordpress.org/trunk@8654 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e621a3239a
commit
d852afb9e9
@ -125,10 +125,10 @@ class WP_Http {
|
||||
if ( is_null($working_transport) ) {
|
||||
if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) )
|
||||
$working_transport[] = new WP_Http_ExtHttp();
|
||||
else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) )
|
||||
$working_transport[] = new WP_Http_Fsockopen();
|
||||
else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) )
|
||||
$working_transport[] = new WP_Http_Streams();
|
||||
else if ( true === WP_Http_Fsockopen::test() && apply_filters('use_fsockopen_transport', true) )
|
||||
$working_transport[] = new WP_Http_Fsockopen();
|
||||
}
|
||||
|
||||
return $working_transport;
|
||||
@ -201,7 +201,7 @@ class WP_Http {
|
||||
}
|
||||
|
||||
if ( isset($r['headers']['User-Agent']) ) {
|
||||
$r['user-agent'] = $headers['User-Agent'];
|
||||
$r['user-agent'] = $r['headers']['User-Agent'];
|
||||
unset($r['headers']['User-Agent']);
|
||||
}
|
||||
|
||||
@ -463,11 +463,21 @@ class WP_Http_Fsockopen {
|
||||
if ( true === $secure_transport )
|
||||
$error_reporting = error_reporting(0);
|
||||
|
||||
$startDelay = time();
|
||||
|
||||
if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) )
|
||||
$handle = @fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] );
|
||||
else
|
||||
$handle = fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] );
|
||||
|
||||
$endDelay = time();
|
||||
|
||||
// If the delay is greater than the timeout then fsockopen should't be
|
||||
// used, because it will cause a long delay.
|
||||
$elapseDelay = ($endDelay-$startDelay) > $r['timeout'];
|
||||
if ( true === $elapseDelay )
|
||||
add_option( 'disable_fsockopen', $endDelay, null, true );
|
||||
|
||||
if ( false === $handle )
|
||||
return new WP_Error('http_request_failed', $iError . ': ' . $strError);
|
||||
|
||||
@ -544,6 +554,9 @@ class WP_Http_Fsockopen {
|
||||
* @return boolean False means this class can not be used, true means it can.
|
||||
*/
|
||||
function test() {
|
||||
if ( false !== ($option = get_option( 'disable_fsockopen' )) && time()-$option < 43200 ) // 12 hours
|
||||
return false;
|
||||
|
||||
if ( function_exists( 'fsockopen' ) )
|
||||
return true;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user