Skip to content

Commit

Permalink
Merge branch 'fix/crash-on-null' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
admturner committed Dec 7, 2023
2 parents c5408c1 + bc04457 commit 01e6003
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@
"scripts": {
"format": "phpcbf --standard=phpcs.xml.dist --report=summary,source",
"lint": "phpcs --colors"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
6 changes: 6 additions & 0 deletions includes/class-wsu-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ public function fetch_api_response() {

// Parse the desired content from the API response.
$this->result = json_decode( wp_remote_retrieve_body( $this->wsu_api_response ), true );

// The WSU API can return a null result with a 200 status code.
if ( ! is_array( $this->result ) ) {
return false;
}

$this->result = array_shift( $this->result );

// Sanitize API data for saving in the database.
Expand Down

0 comments on commit 01e6003

Please sign in to comment.