Skip to content

Commit 3e145a5

Browse files
Merge branch '9.18' into 9.19
2 parents 3367d0b + d87415b commit 3e145a5

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

lib/Gitlab/Api/AbstractApi.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,13 @@ protected function createOptionsResolver()
256256
*/
257257
private function prepareBody(array $parameters = [])
258258
{
259+
$parameters = array_filter($parameters, function ($value) {
260+
return null !== $value;
261+
});
262+
259263
$raw = QueryStringBuilder::build($parameters);
260-
$stream = $this->streamFactory->createStream($raw);
261264

262-
return $stream;
265+
return $this->streamFactory->createStream($raw);
263266
}
264267

265268
/**
@@ -270,6 +273,10 @@ private function prepareBody(array $parameters = [])
270273
*/
271274
private function preparePath($path, array $parameters = [])
272275
{
276+
$parameters = array_filter($parameters, function ($value) {
277+
return null !== $value;
278+
});
279+
273280
if (count($parameters) > 0) {
274281
$path .= '?'.QueryStringBuilder::build($parameters);
275282
}

lib/Gitlab/HttpClient/Message/QueryStringBuilder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ public static function build($query)
2323
{
2424
@trigger_error(sprintf('The %s() method is deprecated since version 9.18 and will be removed in 10.0.', __METHOD__), E_USER_DEPRECATED);
2525

26+
if (is_array($query)) {
27+
$query = array_filter($query, function ($value) {
28+
return null !== $value;
29+
});
30+
}
31+
2632
return UtilQueryStringBuilder::build($query);
2733
}
2834

lib/Gitlab/HttpClient/Util/QueryStringBuilder.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ public static function build($query)
2222
if (!is_array($query)) {
2323
return self::rawurlencode($query);
2424
}
25-
$query = array_filter($query, function ($value) {
26-
return null !== $value;
27-
});
2825

2926
return implode('&', array_map(function ($value, $key) {
3027
return self::encode($value, $key);

test/Gitlab/Tests/HttpClient/Util/QueryStringBuilderTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ public function queryStringProvider()
4545
'source_branch' => 'test_source',
4646
'target_branch' => 'test_master',
4747
'title' => 'test',
48-
'assignee_id' => null,
49-
'target_project_id' => null,
50-
'description' => null,
5148
],
5249
'source_branch=test_source&target_branch=test_master&title=test',
5350
];

0 commit comments

Comments
 (0)