diff --git a/CHANGELOG.md b/CHANGELOG.md index b8a04366..3cf62dab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v8.10.1 (2026-11-30) + +- Fixes `getNextPage` and `getNextPageOfChildren` requesting the same page again when the previous request params already contained a cursor, and ignoring the `pageSize` argument when the previous params had a `page_size`, and sending both `before_id` and `after_id` when the previous params already contained the other cursor (thanks @pcbeingused33) + ## v8.10.0 (2026-11-09) - Adds `delivery_evidence` to `Tracker` and a `DeliveryEvidence` model diff --git a/composer.json b/composer.json index 568d5408..2b240ae3 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "easypost/easypost-php", "description": "EasyPost Shipping API Client Library for PHP", - "version": "8.10.0", + "version": "8.10.1", "keywords": [ "shipping", "api", diff --git a/lib/EasyPost/Constant/Constants.php b/lib/EasyPost/Constant/Constants.php index 567c5f4b..a5b6cd61 100644 --- a/lib/EasyPost/Constant/Constants.php +++ b/lib/EasyPost/Constant/Constants.php @@ -11,7 +11,7 @@ abstract class Constants const BETA_API_VERSION = 'beta'; // Library constants - const LIBRARY_VERSION = '8.10.0'; + const LIBRARY_VERSION = '8.10.1'; const SUPPORT_EMAIL = 'support@easypost.com'; // Validation diff --git a/lib/EasyPost/Service/BaseService.php b/lib/EasyPost/Service/BaseService.php index eace7b91..01a4aab7 100644 --- a/lib/EasyPost/Service/BaseService.php +++ b/lib/EasyPost/Service/BaseService.php @@ -163,13 +163,14 @@ protected function getNextPageResources(string $class, mixed $collection, ?int $ throw new EndOfPaginationException(); } - $params = [ - 'page_size' => $pageSize, + // The new cursor (and page size, if given) must win over the params of the previous request + $params = array_merge($userParams ?? [], [ 'before_id' => $collectionArray[count($collectionArray) - 1]['id'] - ]; + ]); + unset($params['after_id']); - if (isset($userParams)) { - $params = array_merge($params, $userParams); + if (isset($pageSize)) { + $params['page_size'] = $pageSize; } $response = $this->allResources($class, $params); diff --git a/lib/EasyPost/Service/ReportService.php b/lib/EasyPost/Service/ReportService.php index 8093376a..f1fcceaf 100644 --- a/lib/EasyPost/Service/ReportService.php +++ b/lib/EasyPost/Service/ReportService.php @@ -43,6 +43,7 @@ public function all(mixed $params = null): mixed unset($params['type']); $response = Requestor::request($this->client, HttpMethod::GET, $url, $params); $response['type'] = $type; + $response['_params'] = $params; return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -64,13 +65,14 @@ public function getNextPage(mixed $reports, ?int $pageSize = null): mixed throw new EndOfPaginationException(); } - $params = [ - 'page_size' => $pageSize, + // The new cursor (and page size, if given) must win over the params of the previous request + $params = array_merge($userParams ?? [], [ 'before_id' => $reportArray[count($reportArray) - 1]['id'] - ]; + ]); + unset($params['after_id']); - if (isset($userParams)) { - $params = array_merge($params, $userParams); + if (isset($pageSize)) { + $params['page_size'] = $pageSize; } $url = self::reportUrl($reportArray[0]->object); diff --git a/lib/EasyPost/Service/UserService.php b/lib/EasyPost/Service/UserService.php index 21a622bf..7e946779 100644 --- a/lib/EasyPost/Service/UserService.php +++ b/lib/EasyPost/Service/UserService.php @@ -127,13 +127,14 @@ public function getNextPageOfChildren(mixed $children, ?int $pageSize = null): m throw new EndOfPaginationException(); } - $params = [ - 'page_size' => $pageSize, + // The new cursor (and page size, if given) must win over the params of the previous request + $params = array_merge($userParams ?? [], [ 'after_id' => $userArray[count($userArray) - 1]['id'] - ]; + ]); + unset($params['before_id']); - if (isset($userParams)) { - $params = array_merge($params, $userParams); + if (isset($pageSize)) { + $params['page_size'] = $pageSize; } // Retrieve a page of users from the server