WordPress.org

Make WordPress Core

Ticket #8620: 8620-isset-works-best-patch-complete.patch

File 8620-isset-works-best-patch-complete.patch, 2.5 KB (added by hakre, 9 years ago)

Completed patch.

  • wp-includes/http.php

    ### Eclipse Workspace Patch 1.0
    #P wordpress
     
    19621962 * @return array The headers of the response. Empty array if incorrect parameter given.
    19631963 */
    19641964function wp_remote_retrieve_headers(&$response) {
    1965         if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers']))
    1966                 return array();
    1967 
    1968         return $response['headers'];
     1965        return isset($response['headers']) ? ( is_array($response['headers']) ? $response['headers'] : array() ) : array();
    19691966}
    19701967
    19711968/**
     
    19781975 * @return string The header value. Empty string on if incorrect parameter given, or if the header doesnt exist.
    19791976 */
    19801977function wp_remote_retrieve_header(&$response, $header) {
    1981         if ( is_wp_error($response) || ! isset($response['headers']) || ! is_array($response['headers']))
    1982                 return '';
    1983 
    1984         if ( array_key_exists($header, $response['headers']) )
    1985                 return $response['headers'][$header];
    1986 
    1987         return '';
     1978        return isset($response['headers'][$header]) ? $response['headers'][$header] : '';
    19881979}
    19891980
    19901981/**
     
    19971988 * @param array $response HTTP response.
    19981989 * @return string the response code. Empty string on incorrect parameter given.
    19991990 */
    2000 function wp_remote_retrieve_response_code(&$response) {
    2001         if ( is_wp_error($response) ||! isset($response['response']) || ! is_array($response['response']))
    2002                 return '';
    2003 
    2004         return $response['response']['code'];
     1991function wp_remote_retrieve_response_code(&$response) {
     1992        return isset($response['response']['code']) ? $response['response']['code'] : '';
    20051993}
    20061994
    20071995/**
     
    20152003 * @return string The response message. Empty string on incorrect parameter given.
    20162004 */
    20172005function wp_remote_retrieve_response_message(&$response) {
    2018         if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))
    2019                 return '';
    2020 
    2021         return $response['response']['message'];
     2006        return isset($response['response']['message']) ? $response['response']['message'] : '';
    20222007}
    20232008
    20242009/**
     
    20302015 * @return string The body of the response. Empty string if no body or incorrect parameter given.
    20312016 */
    20322017function wp_remote_retrieve_body(&$response) {
    2033         if ( is_wp_error($response) || ! isset($response['body']) )
    2034                 return '';
    2035 
    2036         return $response['body'];
     2018        return isset($response['body']) ? $response['body'] : '';
    20372019}
    20382020
    20392021?>