Skip to content

Commit

Permalink
Fix incorrect parameter checks inside searchCatalogItemsRequest
Browse files Browse the repository at this point in the history
keywords, identifiers, and marketplace_ids can each be comma-separated strings that have a limit on
values. The code was trying to use count() to check for that, which doesn't work. I added explode(",", $var)
to fix this.

Imo, it would make more sense if these parameters were typed as arrays to begin with, but making a change like
that would break existing implementations. This method was chosen so it will "just work" for anyone's existing
usage of the library.
  • Loading branch information
jthistlethwaite committed Apr 28, 2024
1 parent 5b985df commit a767bd1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Api/CatalogItemsV20220401Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -853,15 +853,15 @@ public function searchCatalogItemsRequest($marketplace_ids, $identifiers = null,
'Missing the required parameter $marketplace_ids when calling searchCatalogItems'
);
}
if (count($marketplace_ids) > 1) {
if (count( explode(",", $marketplace_ids) ) > 1) {
throw new \InvalidArgumentException('invalid value for "$marketplace_ids" when calling CatalogItemsV20220401Api.searchCatalogItems, number of items must be less than or equal to 1.');
}

if ($identifiers !== null && count($identifiers) > 20) {
if ($identifiers !== null && count( explode(",", $identifiers) ) > 20) {
throw new \InvalidArgumentException('invalid value for "$identifiers" when calling CatalogItemsV20220401Api.searchCatalogItems, number of items must be less than or equal to 20.');
}

if ($keywords !== null && count($keywords) > 20) {
if ($keywords !== null && count( explode(",", $keywords) ) > 20) {
throw new \InvalidArgumentException('invalid value for "$keywords" when calling CatalogItemsV20220401Api.searchCatalogItems, number of items must be less than or equal to 20.');
}

Expand Down

0 comments on commit a767bd1

Please sign in to comment.