Avoid a fatal error in WP_Http::request() if $response is a WP_Error instance. props dllh, nacin. fixes #24987.
git-svn-id: https://develop.svn.wordpress.org/trunk@25114 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
086c5a8ab8
commit
d2a1a80683
@ -195,16 +195,18 @@ class WP_Http {
|
|||||||
$r['headers']['Content-Length'] = strlen( $r['body'] );
|
$r['headers']['Content-Length'] = strlen( $r['body'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->_dispatch_request($url, $r);
|
$response = $this->_dispatch_request( $url, $r );
|
||||||
|
if ( is_wp_error( $response ) )
|
||||||
|
return $response;
|
||||||
|
|
||||||
// Append cookies that were used in this request to the response
|
// Append cookies that were used in this request to the response
|
||||||
if ( ! empty( $r['cookies'] ) ) {
|
if ( ! empty( $r['cookies'] ) ) {
|
||||||
$cookies_set = wp_list_pluck( $response['cookies'], 'name' );
|
$cookies_set = wp_list_pluck( $response['cookies'], 'name' );
|
||||||
foreach ( $r['cookies'] as $cookie ) {
|
foreach ( $r['cookies'] as $cookie ) {
|
||||||
if ( ! in_array( $cookie->name, $cookies_set ) && $cookie->test( $url ) ) {
|
if ( ! in_array( $cookie->name, $cookies_set ) && $cookie->test( $url ) ) {
|
||||||
$response['cookies'][] = $cookie;
|
$response['cookies'][] = $cookie;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
@ -653,9 +655,9 @@ class WP_Http {
|
|||||||
|
|
||||||
// Include valid cookies in the redirect process
|
// Include valid cookies in the redirect process
|
||||||
if ( ! empty( $response['cookies'] ) ) {
|
if ( ! empty( $response['cookies'] ) ) {
|
||||||
foreach ( $response['cookies'] as $cookie ) {
|
foreach ( $response['cookies'] as $cookie ) {
|
||||||
if ( $cookie->test( $redirect_location ) )
|
if ( $cookie->test( $redirect_location ) )
|
||||||
$args['cookies'][] = $cookie;
|
$args['cookies'][] = $cookie;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user