Skip to content

Commit

Permalink
Better be safe
Browse files Browse the repository at this point in the history
  • Loading branch information
manzoorwanijk committed Dec 10, 2024
1 parent c23edf0 commit 3d387a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion projects/packages/publicize/src/class-connections.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function fetch_connections( $run_tests = false ) {

$response = Client::wpcom_json_api_request_as_user( $path, '3', array(), null, 'wpcom' );

if ( is_wp_error( $response ) ) {
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
// TODO log error.
return array();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ public function get_items( $request ) {

$response = Client::wpcom_json_api_request_as_user( $path, 'v3', array( 'method' => 'GET' ) );

if ( is_wp_error( $response ) ) {
return rest_ensure_response( $response );
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
// TODO log error.
return rest_ensure_response( array() );
}

return rest_ensure_response(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ public function get_items( $request ) {

$response = Client::wpcom_json_api_request_as_user( $path, 'v3', array( 'method' => 'GET' ) );

if ( is_wp_error( $response ) ) {
return rest_ensure_response( $response );
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
// TODO log error.
return rest_ensure_response( array() );
}

return rest_ensure_response(
Expand Down

0 comments on commit 3d387a5

Please sign in to comment.