Skip to content

Commit cda9f39

Browse files
raviks789nilmerg
authored andcommitted
RestApi: Fix jira endpoint deprecation for ticket search
1 parent bc01e66 commit cda9f39

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

library/Jira/RestApi.php

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,20 @@ public function eventuallyGetLatestOpenIssueFor($project, $host, $service = null
128128

129129
$config = Config::module('jira');
130130
$keyField = $config->get('key_fields', 'icingaKey', 'icingaKey');
131-
132-
$issues = $this->post('search', [
131+
$body = [
133132
'jql' => $query,
134-
'startAt' => $start,
135133
'maxResults' => $limit,
136-
'fields' => [ $keyField ],
137-
])->getResult()->issues;
134+
'fields' => [ $keyField ]
135+
];
136+
137+
if (version_compare($this->getJiraVersion(), '10.2', '>=')) {
138+
$url = 'search/jql';
139+
} else {
140+
$url = 'search';
141+
$body['startAt'] = $start;
142+
}
143+
144+
$issues = $this->post($url, $body)->getResult()->issues;
138145

139146
if (empty($issues)) {
140147
Benchmark::measure('Found no (optional) issue');
@@ -261,12 +268,20 @@ public function fetchIssues($host = null, $service = null, $onlyOpen = true)
261268
$keyField,
262269
];
263270

264-
$issues = $this->post('search', [
271+
$body = [
265272
'jql' => $query,
266-
'startAt' => $start,
267273
'maxResults' => $limit,
268-
'fields' => $fields,
269-
])->getResult()->issues;
274+
'fields' => $fields
275+
];
276+
277+
if (version_compare($this->getJiraVersion(), '10.2', '>=')) {
278+
$url = 'search/jql';
279+
} else {
280+
$url = 'search';
281+
$body['startAt'] = $start;
282+
}
283+
284+
$issues = $this->post($url, $body)->getResult()->issues;
270285

271286
Benchmark::measure(sprintf('Fetched %s issues', \count($issues)));
272287

0 commit comments

Comments
 (0)