Adds checking for fsockopen to check for WP_DEBUG and silently drop warnings. Adds streams_set_timeout to fsockopen to help prevent long waits. Props santosj. see #7514

git-svn-id: http://svn.automattic.com/wordpress/trunk@8644 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-08-13 23:37:42 +00:00
parent 9179510fc1
commit 1ef0029be8
2 changed files with 16 additions and 3 deletions

View File

@ -463,11 +463,18 @@ class WP_Http_Fsockopen {
if ( true === $secure_transport )
$error_reporting = error_reporting(0);
$handle = fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] );
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'] );
if ( false === $handle )
return new WP_Error('http_request_failed', $iError . ': ' . $strError);
// WordPress supports PHP 4.3, which has this function. Removed sanity
// checking for performance reasons.
stream_set_timeout($handle, $r['timeout'] );
$requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' );
$requestPath = empty($requestPath) ? '/' : $requestPath;
@ -601,8 +608,9 @@ class WP_Http_Fopen {
if (! $handle)
return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url));
if ( function_exists('stream_set_timeout') )
stream_set_timeout($handle, $r['timeout'] );
// WordPress supports PHP 4.3, which has this function. Removed sanity
// checking for performance reasons.
stream_set_timeout($handle, $r['timeout'] );
if ( ! $r['blocking'] ) {
fclose($handle);
@ -726,6 +734,8 @@ class WP_Http_Streams {
if ( ! $handle)
return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url));
// WordPress supports PHP 4.3, which has this function. Removed sanity
// checking for performance reasons.
stream_set_timeout($handle, $r['timeout'] );
if ( ! $r['blocking'] ) {

View File

@ -145,6 +145,9 @@ function wp_update_plugins() {
$raw_response = wp_remote_request('http://api.wordpress.org/plugins/update-check/1.0/', $options);
if ( is_wp_error( $raw_response ) )
return false;
if( 200 != $raw_response['response']['code'] ) {
return false;
}