WordPress.org

Make WordPress Core

Changeset 25114


Ignore:
Timestamp:
08/24/2013 03:10:16 AM (7 years ago)
Author:
SergeyBiryukov
Message:

Avoid a fatal error in WP_Http::request() if $response is a WP_Error instance. props dllh, nacin. fixes #24987.

File:
1 edited

Legend:

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

    r25051 r25114  
    196196        }
    197197
    198         $response = $this->_dispatch_request($url, $r);
     198        $response = $this->_dispatch_request( $url, $r );
     199        if ( is_wp_error( $response ) )
     200            return $response;
    199201
    200202        // Append cookies that were used in this request to the response
    201203        if ( ! empty( $r['cookies'] ) ) {
    202             $cookies_set = wp_list_pluck( $response['cookies'], 'name' );
    203             foreach ( $r['cookies'] as $cookie ) {
    204                     if ( ! in_array( $cookie->name, $cookies_set ) && $cookie->test( $url ) ) {
    205                                 $response['cookies'][] = $cookie;
    206                     }
    207             }
     204            $cookies_set = wp_list_pluck( $response['cookies'], 'name' );
     205            foreach ( $r['cookies'] as $cookie ) {
     206                if ( ! in_array( $cookie->name, $cookies_set ) && $cookie->test( $url ) ) {
     207                    $response['cookies'][] = $cookie;
     208                }
     209            }
    208210        }
    209211
     
    654656        // Include valid cookies in the redirect process
    655657        if ( ! empty( $response['cookies'] ) ) {
    656             foreach ( $response['cookies'] as $cookie ) {
    657                 if ( $cookie->test( $redirect_location ) )
    658                         $args['cookies'][] = $cookie;
     658            foreach ( $response['cookies'] as $cookie ) {
     659                if ( $cookie->test( $redirect_location ) )
     660                    $args['cookies'][] = $cookie;
    659661            }
    660662        }
Note: See TracChangeset for help on using the changeset viewer.