|
10 | 10 | use Redmine\Exception\MissingParameterException; |
11 | 11 | use Redmine\Exception\SerializerException; |
12 | 12 | use Redmine\Exception\UnexpectedResponseException; |
| 13 | +use Redmine\Future; |
13 | 14 | use Redmine\Http\HttpClient; |
14 | 15 | use Redmine\Http\HttpFactory; |
15 | 16 | use Redmine\Serializer\JsonSerializer; |
@@ -274,6 +275,15 @@ public function create($project, array $params = []) |
274 | 275 | )); |
275 | 276 |
|
276 | 277 | $body = $this->lastResponse->getContent(); |
| 278 | + $statusCode = $this->lastResponse->getStatusCode(); |
| 279 | + |
| 280 | + if ($statusCode !== 201) { |
| 281 | + if (!Future::isForwardCompatibilityEnabled()) { |
| 282 | + return $body; |
| 283 | + } |
| 284 | + |
| 285 | + throw UnexpectedResponseException::create($this->lastResponse); |
| 286 | + } |
277 | 287 |
|
278 | 288 | if ('' !== $body) { |
279 | 289 | return new SimpleXMLElement($body); |
@@ -311,7 +321,18 @@ public function update($id, array $params) |
311 | 321 | XmlSerializer::createFromArray(['version' => $params])->getEncoded(), |
312 | 322 | )); |
313 | 323 |
|
314 | | - return $this->lastResponse->getContent(); |
| 324 | + $body = $this->lastResponse->getContent(); |
| 325 | + $statusCode = $this->lastResponse->getStatusCode(); |
| 326 | + |
| 327 | + if ($statusCode !== 200 && $statusCode !== 204) { |
| 328 | + if (!Future::isForwardCompatibilityEnabled()) { |
| 329 | + return $body; |
| 330 | + } |
| 331 | + |
| 332 | + throw UnexpectedResponseException::create($this->lastResponse); |
| 333 | + } |
| 334 | + |
| 335 | + return $body; |
315 | 336 | } |
316 | 337 |
|
317 | 338 | /** |
@@ -368,7 +389,18 @@ public function remove($id) |
368 | 389 | '/versions/' . $id . '.xml', |
369 | 390 | )); |
370 | 391 |
|
371 | | - return $this->lastResponse->getContent(); |
| 392 | + $body = $this->lastResponse->getContent(); |
| 393 | + $statusCode = $this->lastResponse->getStatusCode(); |
| 394 | + |
| 395 | + if ($statusCode !== 200 && $statusCode !== 204) { |
| 396 | + if (!Future::isForwardCompatibilityEnabled()) { |
| 397 | + return $body; |
| 398 | + } |
| 399 | + |
| 400 | + throw UnexpectedResponseException::create($this->lastResponse); |
| 401 | + } |
| 402 | + |
| 403 | + return $body; |
372 | 404 | } |
373 | 405 |
|
374 | 406 | /** |
|
0 commit comments