Skip to content

Commit db7b229

Browse files
committed
ref #253 workaround for v3 search api
1 parent f7c3fcd commit db7b229

File tree

4 files changed

+45
-33
lines changed

4 files changed

+45
-33
lines changed

src/Issue/IssueFieldV3.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,6 @@ class IssueFieldV3 extends IssueField
1414
/** @var \JiraRestApi\Issue\DescriptionV3|null */
1515
public $environment;
1616

17-
public function jsonSerialize()
18-
{
19-
$vars = array_filter(get_object_vars($this), function ($var) {
20-
return !is_null($var);
21-
});
22-
23-
// if assignee property has empty value then remove it.
24-
// @see https://github.com/lesstif/php-jira-rest-client/issues/126
25-
// @see https://github.com/lesstif/php-jira-rest-client/issues/177
26-
if (!empty($this->assignee)) {
27-
// do nothing
28-
if ($this->assignee->isWantUnassigned() === true) {
29-
} elseif ($this->assignee->isEmpty()) {
30-
unset($vars['assignee']);
31-
}
32-
}
33-
34-
// clear undefined json property
35-
unset($vars['customFields']);
36-
37-
// repackaging custom field
38-
if (!empty($this->customFields)) {
39-
foreach ($this->customFields as $key => $value) {
40-
$vars[$key] = $value;
41-
}
42-
}
43-
44-
return $vars;
45-
}
46-
4717
/**
4818
* @param \JiraRestApi\Issue\DescriptionV3|null $description
4919
*

src/Issue/IssueSearchResultV3.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace JiraRestApi\Issue;
4+
5+
/**
6+
* Issue search result.
7+
*/
8+
class IssueSearchResultV3 extends IssueSearchResult
9+
{
10+
/**
11+
* @var \JiraRestApi\Issue\IssueV3[]
12+
*/
13+
public $issues;
14+
15+
/**
16+
* @return \JiraRestApi\Issue\IssueV3[]
17+
*/
18+
public function getIssues()
19+
{
20+
return $this->issues;
21+
}
22+
23+
/**
24+
* @param \JiraRestApi\Issue\IssueV3[] $issues
25+
*/
26+
public function setIssues($issues)
27+
{
28+
$this->issues = $issues;
29+
}
30+
}

src/Issue/IssueService.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,16 @@ public function search($jql, $startAt = 0, $maxResults = 15, $fields = [], $expa
522522
$ret = $this->exec('search', $data, 'POST');
523523
$json = json_decode($ret);
524524

525-
$result = $this->json_mapper->map(
526-
$json, new IssueSearchResult()
527-
);
525+
$result = null;
526+
if ($this->isRestApiV3()) {
527+
$result = $this->json_mapper->map(
528+
$json, new IssueSearchResultV3()
529+
);
530+
} else {
531+
$result = $this->json_mapper->map(
532+
$json, new IssueSearchResult()
533+
);
534+
}
528535

529536
return $result;
530537
}

src/Issue/IssueV3.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,9 @@ class IssueV3 extends Issue
66
{
77
/** @var \JiraRestApi\Issue\IssueFieldV3 */
88
public $fields;
9+
10+
public function jsonSerialize()
11+
{
12+
return array_filter(get_object_vars($this));
13+
}
914
}

0 commit comments

Comments
 (0)