Skip to content

Commit da3a295

Browse files
authored
Merge pull request #3451 from webant-ltd/fix-error-pagination
Fix error pagination
2 parents 3716126 + 84fb363 commit da3a295

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

features/jsonapi/pagination.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ Feature: JSON API pagination handling
3636
Scenario: Get an error when provided page number is not valid
3737
When I send a "GET" request to "/dummies?page[page]=0"
3838
Then the response status code should be 400
39+
40+
Scenario: Get an error when provided page number is too large
41+
When I send a "GET" request to "/dummies?page[page]=9223372036854775807"
42+
Then the response status code should be 400

src/DataProvider/Pagination.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ public function getOffset(string $resourceClass = null, string $operationName =
9191
return ($offset = ($context['count'] ?? 0) - $last) < 0 ? 0 : $offset;
9292
}
9393

94-
return ($this->getPage($context) - 1) * $limit;
94+
$offset = ($this->getPage($context) - 1) * $limit;
95+
96+
if (!\is_int($offset)) {
97+
throw new InvalidArgumentException('Page parameter is too large.');
98+
}
99+
100+
return $offset;
95101
}
96102

97103
/**

0 commit comments

Comments
 (0)