Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support avatarId key in IssueType, throw Exception if response is not a JSON #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Jira/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use chobie\Jira\Api\Client\ClientInterface;
use chobie\Jira\Api\Result;
use chobie\Jira\Api\Client\CurlClient;
use chobie\Jira\Api\Exception;

class Api
{
Expand Down Expand Up @@ -469,6 +470,10 @@ public function api(

if (strlen($result)) {
$json = json_decode($result, true);
if (!is_array($json)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to check for null specifically as this clearly indicates the error. Not sure if that won't backfire if some of API calls really has returns null.

throw new Exception("JIRA Rest server returns unexpected result: " . $result);
}

if ($this->options & self::AUTOMAP_FIELDS) {
if (isset($json['issues'])) {
if (!count($this->fields)) {
Expand Down
3 changes: 2 additions & 1 deletion src/Jira/IssueType.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class IssueType
"iconUrl",
"name",
"subtask",
"avatarId",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert changes to this file, because avatar support was added in #50.

);

public function __construct($types)
Expand Down Expand Up @@ -82,4 +83,4 @@ public function getIconUrl()
{
return $this->iconUrl;
}
}
}