Skip to content

Commit 3e0a398

Browse files
Merge branch '10.4' into 11.0
2 parents 3ba0982 + 5451dde commit 3e0a398

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
## [10.4.0] - UPCOMING
1616

17-
[10.4.0]: https://github.com/GitLabPHP/Client/compare/10.3.0...10.4.0
17+
[10.4.0]: https://github.com/GitLabPHP/Client/compare/10.3.1...10.4.0
18+
19+
## [10.3.1] - 2020-12-04
20+
21+
* Work around GitLab's API returning bad JSON for some endpoints
22+
23+
[10.3.0]: https://github.com/GitLabPHP/Client/compare/10.3.0...10.3.1
1824

1925
## [10.3.0] - 2020-11-27
2026

src/Api/AbstractApi.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ private function createMultipartStreamBuilder(array $params = [], array $files =
271271
foreach ($files as $name => $file) {
272272
$builder->addResource($name, self::tryFopen($file, 'r'), [
273273
'headers' => [
274-
'Content-Type' => self::guessFileContentType($file),
274+
ResponseMediator::CONTENT_TYPE_HEADER => self::guessFileContentType($file),
275275
],
276276
'filename' => \basename($file),
277277
]);
@@ -304,7 +304,7 @@ private static function addMultipartContentType(array $headers, MultipartStreamB
304304
{
305305
$contentType = \sprintf('%s; boundary=%s', ResponseMediator::MULTIPART_CONTENT_TYPE, $builder->getBoundary());
306306

307-
return \array_merge(['Content-Type' => $contentType], $headers);
307+
return \array_merge([ResponseMediator::CONTENT_TYPE_HEADER => $contentType], $headers);
308308
}
309309

310310
/**
@@ -336,7 +336,7 @@ private static function prepareJsonBody(array $params)
336336
*/
337337
private static function addJsonContentType(array $headers)
338338
{
339-
return \array_merge(['Content-Type' => ResponseMediator::JSON_CONTENT_TYPE], $headers);
339+
return \array_merge([ResponseMediator::CONTENT_TYPE_HEADER => ResponseMediator::JSON_CONTENT_TYPE], $headers);
340340
}
341341

342342
/**

src/Api/Groups.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ class Groups extends AbstractApi
1212
/**
1313
* @param array $parameters {
1414
*
15-
* @var int[] $skip_groups skip the group IDs passes
16-
* @var bool $all_available show all the groups you have access to
17-
* @var string $search return list of authorized groups matching the search criteria
18-
* @var string $order_by Order groups by name or path (default is name)
19-
* @var string $sort Order groups in asc or desc order (default is asc)
20-
* @var bool $statistics include group statistics (admins only)
21-
* @var bool $owned limit by groups owned by the current user
15+
* @var int[] $skip_groups skip the group IDs passes
16+
* @var bool $all_available show all the groups you have access to
17+
* @var string $search return list of authorized groups matching the search criteria
18+
* @var string $order_by Order groups by name or path (default is name)
19+
* @var string $sort Order groups in asc or desc order (default is asc)
20+
* @var bool $statistics include group statistics (admins only)
21+
* @var bool $owned limit by groups owned by the current user
22+
* @var int $min_access_level limit by groups in which the current user has at least this access level
2223
* }
2324
*
2425
* @return mixed
@@ -446,6 +447,9 @@ private function getGroupSearchResolver()
446447
->setAllowedTypes('owned', 'bool')
447448
->setNormalizer('owned', $booleanNormalizer)
448449
;
450+
$resolver->setDefined('min_access_level')
451+
->setAllowedValues('min_access_level', [null, 10, 20, 30, 40, 50])
452+
;
449453

450454
return $resolver;
451455
}

src/HttpClient/Message/ResponseMediator.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
*/
1414
final class ResponseMediator
1515
{
16+
/**
17+
* The content type header.
18+
*
19+
* @var string
20+
*/
21+
public const CONTENT_TYPE_HEADER = 'Content-Type';
22+
1623
/**
1724
* The JSON content type identifier.
1825
*
@@ -45,7 +52,7 @@ public static function getContent(ResponseInterface $response)
4552
{
4653
$body = (string) $response->getBody();
4754

48-
if ('' !== $body && 0 === \strpos($response->getHeaderLine('Content-Type'), self::JSON_CONTENT_TYPE)) {
55+
if (!\in_array($body, ['', 'null', 'true', 'false'], true) && 0 === \strpos($response->getHeaderLine(self::CONTENT_TYPE_HEADER), self::JSON_CONTENT_TYPE)) {
4956
return JsonArray::decode($body);
5057
}
5158

0 commit comments

Comments
 (0)