-
Notifications
You must be signed in to change notification settings - Fork 382
Closed
Description
Version : 1.1.1
When fetching external stylesheet failure that indicated by WP_Error on wp_remote_get, there is no code and message displayed on Validations Page.
Example case : when Invalid SSL being used on external stylesheet url.
This is caused by wp_remote_retrieve_response_code and wp_remote_retrieve_response_message are empty
private function fetch_external_stylesheet( $url ) {
$cache_key = md5( $url );
$contents = get_transient( $cache_key );
if ( false === $contents ) {
$r = wp_remote_get( $url );
// TODO: Need to handle WP_Error
if ( 200 !== wp_remote_retrieve_response_code( $r ) ) {
$contents = new WP_Error(
wp_remote_retrieve_response_code( $r ),
wp_remote_retrieve_response_message( $r )
);
} elseif ( ! preg_match( '#^text/css#', wp_remote_retrieve_header( $r, 'content-type' ) ) ) {
$contents = new WP_Error(
'no_css_content_type',
__( 'Response did not contain the expected text/css content type.', 'amp' )
);
} else {
$contents = wp_remote_retrieve_body( $r );
}
set_transient( $cache_key, $contents, MONTH_IN_SECONDS );
}
return $contents;
}Possible Solution : Add WP_Error handler after wp_remote_get to catch code and message, that will be usable on later stage
Reactions are currently unavailable