WordPress.org

Make WordPress Core

Ticket #7793: 7793.r9046.diff

File 7793.r9046.diff, 2.3 KB (added by jacobsantos, 10 years ago)

Error checking for the HTTP API based off of r9046

  • wp-admin/update-links.php

     
    3838
    3939$response = wp_remote_get('http://api.pingomatic.com/updated-batch/', $options);
    4040
     41if ( is_wp_error( $response ) )
     42        wp_die(__('Request Failed.'));
     43
    4144if ( $response['response']['code'] != 200 )
    4245        wp_die(__('Request Failed.'));
    4346
  • wp-includes/comment.php

     
    13161316                'excerpt' => urlencode($excerpt)
    13171317        );
    13181318
    1319         wp_remote_post($trackback_url, $options);
     1319        $response = wp_remote_post($trackback_url, $options);
     1320       
     1321        if ( is_wp_error( $response ) )
     1322                return;
    13201323
    13211324        $tb_url = addslashes( $trackback_url );
    13221325        $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = %d", $ID) );
  • wp-includes/functions.php

     
    10391039
    10401040        $response = wp_remote_request($url, $options);
    10411041
     1042        if ( is_wp_error( $response ) )
     1043                return false;
     1044
    10421045        $headers = wp_remote_retrieve_headers( $response );
    10431046        if ( false == $file_path )
    10441047                return $headers;
     
    10721075 */
    10731076function wp_get_http_headers( $url, $deprecated = false ) {
    10741077        $response = wp_remote_head( $url );
     1078
     1079        if ( is_wp_error( $response ) )
     1080                return false;
     1081
    10751082        return wp_remote_retrieve_headers( $response );
    10761083}
    10771084
     
    12401247 * @uses wp_remote_get()
    12411248 *
    12421249 * @param string $uri URI/URL of web page to retrieve.
    1243  * @return string HTTP content.
     1250 * @return bool|string HTTP content. False on failure.
    12441251 */
    12451252function wp_remote_fopen( $uri ) {
    1246         // parse url() should not be used for validation of URLs.
    1247         // Keeping anyway, since the Filter extension is not available on all servers.
    12481253        $parsed_url = @parse_url( $uri );
    12491254
    12501255        if ( !$parsed_url || !is_array( $parsed_url ) )
     
    12551260
    12561261        $response = wp_remote_get( $uri, $options );
    12571262
     1263        if ( is_wp_error( $response ) )
     1264                return false;
     1265
    12581266        return $response['body'];
    12591267}
    12601268