WordPress.org

Make WordPress Core

Changeset 8644


Ignore:
Timestamp:
08/13/08 23:37:42 (7 years ago)
Author:
ryan
Message:

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

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/http.php

    r8634 r8644  
    464464            $error_reporting = error_reporting(0); 
    465465 
    466         $handle = fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] ); 
     466        if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) 
     467            $handle = @fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] ); 
     468        else 
     469            $handle = fsockopen($arrURL['host'], $arrURL['port'], $iError, $strError, $r['timeout'] ); 
    467470 
    468471        if ( false === $handle ) 
    469472            return new WP_Error('http_request_failed', $iError . ': ' . $strError); 
     473 
     474        // WordPress supports PHP 4.3, which has this function. Removed sanity 
     475        // checking for performance reasons. 
     476        stream_set_timeout($handle, $r['timeout'] ); 
    470477 
    471478        $requestPath = $arrURL['path'] . ( isset($arrURL['query']) ? '?' . $arrURL['query'] : '' ); 
     
    602609            return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url)); 
    603610 
    604         if ( function_exists('stream_set_timeout') ) 
    605             stream_set_timeout($handle, $r['timeout'] ); 
     611        // WordPress supports PHP 4.3, which has this function. Removed sanity 
     612        // checking for performance reasons. 
     613        stream_set_timeout($handle, $r['timeout'] ); 
    606614 
    607615        if ( ! $r['blocking'] ) { 
     
    727735            return new WP_Error('http_request_failed', sprintf(__('Could not open handle for fopen() to %s'), $url)); 
    728736 
     737        // WordPress supports PHP 4.3, which has this function. Removed sanity 
     738        // checking for performance reasons. 
    729739        stream_set_timeout($handle, $r['timeout'] ); 
    730740 
  • trunk/wp-includes/update.php

    r8630 r8644  
    146146    $raw_response = wp_remote_request('http://api.wordpress.org/plugins/update-check/1.0/', $options); 
    147147 
     148    if ( is_wp_error( $raw_response ) ) 
     149        return false; 
     150 
    148151    if( 200 != $raw_response['response']['code'] ) { 
    149152        return false; 
Note: See TracChangeset for help on using the changeset viewer.