From a767bd17af9b3649bcd95fddd487e62bfca52fd5 Mon Sep 17 00:00:00 2001 From: Jason Thistlethwaite Date: Sun, 28 Apr 2024 11:51:35 -0400 Subject: [PATCH] Fix incorrect parameter checks inside searchCatalogItemsRequest 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. --- lib/Api/CatalogItemsV20220401Api.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Api/CatalogItemsV20220401Api.php b/lib/Api/CatalogItemsV20220401Api.php index 17e34da4f..3024bf70e 100644 --- a/lib/Api/CatalogItemsV20220401Api.php +++ b/lib/Api/CatalogItemsV20220401Api.php @@ -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.'); }