diff --git a/features/jsonapi/pagination.feature b/features/jsonapi/pagination.feature index d07aacf3b48..e8176df72d8 100644 --- a/features/jsonapi/pagination.feature +++ b/features/jsonapi/pagination.feature @@ -36,3 +36,7 @@ Feature: JSON API pagination handling Scenario: Get an error when provided page number is not valid When I send a "GET" request to "/dummies?page[page]=0" Then the response status code should be 400 + + Scenario: Get an error when provided page number is too large + When I send a "GET" request to "/dummies?page[page]=9223372036854775807" + Then the response status code should be 400 diff --git a/src/DataProvider/Pagination.php b/src/DataProvider/Pagination.php index 8a9bc41b9cd..aeab11b3e81 100644 --- a/src/DataProvider/Pagination.php +++ b/src/DataProvider/Pagination.php @@ -91,7 +91,13 @@ public function getOffset(string $resourceClass = null, string $operationName = return ($offset = ($context['count'] ?? 0) - $last) < 0 ? 0 : $offset; } - return ($this->getPage($context) - 1) * $limit; + $offset = ($this->getPage($context) - 1) * $limit; + + if (!\is_int($offset)) { + throw new InvalidArgumentException('Page parameter is too large.'); + } + + return $offset; } /**