Skip to content

Commit 58f4c6a

Browse files
authored
Feature/con 519 api requests auditing (#831)
* early return if no response body * capitalization touchup
1 parent f49c10f commit 58f4c6a

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

includes/class-api.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,11 +1614,16 @@ private function exec( $url, $options ): bool {
16141614
$this->status_code = 0;
16151615

16161616
if ( ! is_wp_error( $response ) ) {
1617-
1617+
if ( empty( $response['body'] ) ) {
1618+
constant_contact_maybe_log_it(
1619+
'Response error: ', implode( ":", $response['response'] )
1620+
);
1621+
return false;
1622+
}
16181623
$data = json_decode( $response['body'], true );
16191624
$json_last_error = json_last_error();
16201625
if ( JSON_ERROR_NONE !== $json_last_error ) {
1621-
constant_contact_maybe_log_it( 'JSON Error: ', json_last_error_msg() );
1626+
constant_contact_maybe_log_it( 'JSON error: ', json_last_error_msg() );
16221627
}
16231628

16241629
// check if the body contains error

0 commit comments

Comments
 (0)