Skip to content

Commit 379b89f

Browse files
Better forwards compatability with the next major release
1 parent 4177fa7 commit 379b89f

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
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);

0 commit comments

Comments
 (0)