From 0b7ce94a88b14d11fcbf58cc378646f4572b260c Mon Sep 17 00:00:00 2001 From: Ismail Cherri Date: Sun, 27 Mar 2016 16:19:50 +0200 Subject: [PATCH] FIX: PHP Notices when response body is empty --- src/helixware_server.php | 2 +- src/includes/class-helixware-hal-response.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helixware_server.php b/src/helixware_server.php index 1a1ff58..1364f4b 100644 --- a/src/helixware_server.php +++ b/src/helixware_server.php @@ -87,6 +87,6 @@ function hewa_server_call( $response = hewa_server_request( $endpoint, 'GET', '', $content_type, $accept ); // Return the response as a string. - return $response['body']; + return isset($response['body']) ? $response['body'] : ''; } diff --git a/src/includes/class-helixware-hal-response.php b/src/includes/class-helixware-hal-response.php index bb3fa47..061db90 100644 --- a/src/includes/class-helixware-hal-response.php +++ b/src/includes/class-helixware-hal-response.php @@ -37,7 +37,7 @@ public function __construct( $hal_client, $response ) { $this->hal_client = $hal_client; $this->response = $response; - $this->body_json = json_decode( $response['body'] ); + $this->body_json = json_decode( isset($response['body']) ? $response['body'] : NULL); $this->links = ( isset( $this->body_json->_links ) ? $this->body_json->_links : NULL ); $this->embedded = ( isset( $this->body_json->_embedded ) ? $this->body_json->_embedded : NULL );