@@ -320,13 +320,16 @@ protected function retrieveData(string $endpoint, array $params = []): array
320
320
321
321
$ returnData = [];
322
322
323
+ // Redmine max limit is 100,
324
+ // @see https://www.redmine.org/projects/redmine/wiki/Rest_api#Collection-resources-and-pagination
325
+ $ redmineLimit = 100 ;
323
326
$ requestedLimit = $ remaininglimit = $ params ['limit ' ];
324
327
$ offset = $ params ['offset ' ];
325
328
326
329
while ($ remaininglimit > 0 ) {
327
- if ($ remaininglimit > 100 ) {
328
- $ realLimit = 100 ;
329
- $ remaininglimit -= 100 ;
330
+ if ($ remaininglimit > $ redmineLimit ) {
331
+ $ realLimit = $ redmineLimit ;
332
+ $ remaininglimit -= $ redmineLimit ;
330
333
} else {
331
334
$ realLimit = $ remaininglimit ;
332
335
$ remaininglimit = 0 ;
@@ -347,13 +350,13 @@ protected function retrieveData(string $endpoint, array $params = []): array
347
350
// After the first request we know the total_count for this endpoint
348
351
// so lets use the total_count to correct $requestedLimit to save us
349
352
// from making unnecessary requests
350
- // e.g. total_count = 5; $requestedLimit = 500 will make only 1 request instead of 5
353
+ // e.g. total_count = 5 and $requestedLimit = 500 will make only 1 request instead of 2
351
354
if (isset ($ newDataSet ['total_count ' ]) && $ newDataSet ['total_count ' ] < $ requestedLimit ) {
352
355
$ requestedLimit = $ remaininglimit = (int ) $ newDataSet ['total_count ' ];
353
356
354
- if ($ remaininglimit > 100 ) {
355
- $ realLimit = 100 ;
356
- $ remaininglimit -= 100 ;
357
+ if ($ remaininglimit > $ redmineLimit ) {
358
+ $ realLimit = $ redmineLimit ;
359
+ $ remaininglimit -= $ redmineLimit ;
357
360
} else {
358
361
$ realLimit = $ remaininglimit ;
359
362
$ remaininglimit = 0 ;
0 commit comments