Make WordPress Core


Ignore:
Timestamp:
07/06/2016 05:50:44 PM (10 years ago)
Author:
rmccue
Message:

HTTP API: Switch back to returning an array.

The array-compatibility object we started returning in r37428 unfortunately isn't enough like an array. In particular, is_array() checks fail, despite the object implementing ArrayAccess. Mea culpa.

This moves the WP_HTTP_Response object to a new http_response key in the array, and changes the value back to an actual array.

Fixes #37097.
See #33055.

File:
1 edited

Legend:

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

    r37674 r37989  
    349349
    350350                try {
    351                         $response = Requests::request( $url, $headers, $data, $type, $options );
     351                        $requests_response = Requests::request( $url, $headers, $data, $type, $options );
    352352
    353353                        // Convert the response into an array
    354                         $response = new WP_HTTP_Requests_Response( $response, $r['filename'] );
     354                        $http_response = new WP_HTTP_Requests_Response( $requests_response, $r['filename'] );
     355                        $response = $http_response->to_array();
     356
     357                        // Add the original object to the array.
     358                        $response['http_response'] = $http_response;
    355359                }
    356360                catch ( Requests_Exception $e ) {
    … …  
    383387                                ),
    384388                                'cookies' => array(),
     389                                'http_response' => null,
    385390                        );
    386391                }
Note: See TracChangeset for help on using the changeset viewer.