Make WordPress Core

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

File 8620-isset-works-best-patch.patch, 1.7 KB (added by hakre, 14 years ago)

isset() just checks and does not throw any warings. but the last patch can (because you did't check subitems or arrays). less code, more functionality. KISS by me.

  • wp-includes/http.php

    ### Eclipse Workspace Patch 1.0
    #P wordpress
     
    19781978 * @return string The header value. Empty string on if incorrect parameter given, or if the header doesnt exist.
    19791979 */
    19801980function 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 '';
     1981        return isset($response['headers'][$header]) ? $response['headers'][$header] : '';
    19881982}
    19891983
    19901984/**
     
    19971991 * @param array $response HTTP response.
    19981992 * @return string the response code. Empty string on incorrect parameter given.
    19991993 */
    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'];
     1994function wp_remote_retrieve_response_code(&$response) {
     1995        return isset($response['response']['code']) ? $response['response']['code'] : '';
    20051996}
    20061997
    20071998/**
     
    20152006 * @return string The response message. Empty string on incorrect parameter given.
    20162007 */
    20172008function 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'];
     2009        return isset($response['response']['message']) ? $response['response']['message'] : '';
    20222010}
    20232011
    20242012/**