Skip to content

Commit

Permalink
Prevent array access on null
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandruGG committed Sep 1, 2020
1 parent fb57d55 commit 1e8fa1e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/PodioError.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public function __construct($body, $status, $url) {
$this->body = json_decode($body, TRUE);
$this->status = $status;
$this->url = $url;
$this->request = $this->body['request'];
$this->request = isset($this->body['request']) ? $this->body['request'] : array();
parent::__construct(get_class($this), 1, null);
}

Expand All @@ -17,7 +17,9 @@ public function __toString() {
if (!empty($this->body['error_description'])) {
$str .= ': "'.$this->body['error_description'].'"';
}
$str .= "\nRequest URL: ".$this->request['url'];
if (!empty($this->request['url'])) {
$str .= "\nRequest URL: ".$this->request['url'];
}
if (!empty($this->request['query_string'])) {
$str .= '?'.$this->request['query_string'];
}
Expand Down

0 comments on commit 1e8fa1e

Please sign in to comment.