Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: fields that are set to 0 are erroneously removed from request payload #370

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased
## v5.6.2 - 2024-09-23

- [#370](https://github.com/Shopify/shopify-api-php/pull/370) [Patch] Fix params set to zero being removed from request payload
lizkenyon marked this conversation as resolved.
Show resolved Hide resolved

## v5.6.1 - 2024-09-06

Expand Down
1 change: 0 additions & 1 deletion src/Rest/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ protected static function request(

$client = new Rest($session->getShop(), $session->getAccessToken());

$params = array_filter($params);
lizkenyon marked this conversation as resolved.
Show resolved Hide resolved
switch ($httpMethod) {
case "get":
$response = $client->get(
Expand Down
18 changes: 18 additions & 0 deletions tests/Clients/BaseRestResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ public function testFindsWithParam()
$this->assertEquals([1, "attribute"], [$resource->id, $resource->attribute]);
}

public function testCanUseFalseyParams()
andy-liuu marked this conversation as resolved.
Show resolved Hide resolved
{
$body = ["fake_resource" => ["id" => 1, "attribute" => "attribute"]];

$this->mockTransportRequests([
new MockRequest(
$this->buildMockHttpResponse(200, $body),
"{$this->prefix}/fake_resources/1.json?param=0",
"GET",
null,
["X-Shopify-Access-Token: access-token"],
),
]);

$resource = FakeResource::find($this->session, 1, ["param" => "0"]);
$this->assertEquals([1, "attribute"], [$resource->id, $resource->attribute]);
}

public function testFindsResourceAndChildrenById()
{
$body = ["fake_resource" => [
Expand Down
Loading