WordPress.org

Make WordPress Core

Ticket #8620: 8620-http-php-api--method-improvements-docblocks-and-robustness.patch

File 8620-http-php-api--method-improvements-docblocks-and-robustness.patch, 1.7 KB (added by hakre, 9 years ago)

patch as describben in my comment. fixes 8620 in the current codebase and corrects return types (in docblocks)

  • wp-includes/http.php

     
    19781978 * @return array The header value. Empty string on if incorrect parameter given.
    19791979 */
    19801980function wp_remote_retrieve_header(&$response, $header) {
    1981         if ( ! 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/**
     
    19951989 * @since 2.7.0
    19961990 *
    19971991 * @param array $response HTTP response.
    1998  * @return array The keys 'code' and 'message' give information on the response.
     1992 * @return string Response Code. Empty string on failure.
    19991993 */
    2000 function wp_remote_retrieve_response_code(&$response) {
    2001         if ( ! 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/**
     
    20122003 * @since 2.7.0
    20132004 *
    20142005 * @param array $response HTTP response.
    2015  * @return array The keys 'code' and 'message' give information on the response.
     2006 * @return string Response Message. Empty string on failure.
    20162007 */
    20172008function wp_remote_retrieve_response_message(&$response) {
    2018         if ( ! 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/**