WordPress.org

Make WordPress Core

Ticket #8620: 8620-isset-works-best-patch-less-complex-flow.patch

File 8620-isset-works-best-patch-less-complex-flow.patch, 2.6 KB (added by hakre, 9 years ago)
  • wp-includes/http.php

    ### Eclipse Workspace Patch 1.0
    #P wordpress
     
    19611961 * @param array $response HTTP response.
    19621962 * @return array The headers of the response. Empty array if incorrect parameter given.
    19631963 */
    1964 function 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'];
     1964function wp_remote_retrieve_headers(&$response) {       
     1965        if ( isset($response['headers']) && is_array($response['headers']) )
     1966                return $response['headers'];   
     1967        return array();
    19691968}
    19701969
    19711970/**
     
    19781977 * @return string The header value. Empty string on if incorrect parameter given, or if the header doesnt exist.
    19791978 */
    19801979function 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 '';
     1980        return isset($response['headers'][$header]) ? $response['headers'][$header] : '';
    19881981}
    19891982
    19901983/**
     
    19971990 * @param array $response HTTP response.
    19981991 * @return string the response code. Empty string on incorrect parameter given.
    19991992 */
    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'];
     1993function wp_remote_retrieve_response_code(&$response) {
     1994        return isset($response['response']['code']) ? $response['response']['code'] : '';
    20051995}
    20061996
    20071997/**
     
    20152005 * @return string The response message. Empty string on incorrect parameter given.
    20162006 */
    20172007function 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'];
     2008        return isset($response['response']['message']) ? $response['response']['message'] : '';
    20222009}
    20232010
    20242011/**
     
    20302017 * @return string The body of the response. Empty string if no body or incorrect parameter given.
    20312018 */
    20322019function wp_remote_retrieve_body(&$response) {
    2033         if ( is_wp_error($response) || ! isset($response['body']) )
    2034                 return '';
    2035 
    2036         return $response['body'];
     2020        return isset($response['body']) ? $response['body'] : '';
    20372021}
    20382022
    20392023?>