@@ -320,13 +320,16 @@ protected function retrieveData(string $endpoint, array $params = []): array
320320
321321 $ returnData = [];
322322
323+ // Redmine max limit is 100,
324+ // @see https://www.redmine.org/projects/redmine/wiki/Rest_api#Collection-resources-and-pagination
325+ $ redmineLimit = 100 ;
323326 $ requestedLimit = $ remaininglimit = $ params ['limit ' ];
324327 $ offset = $ params ['offset ' ];
325328
326329 while ($ remaininglimit > 0 ) {
327- if ($ remaininglimit > 100 ) {
328- $ realLimit = 100 ;
329- $ remaininglimit -= 100 ;
330+ if ($ remaininglimit > $ redmineLimit ) {
331+ $ realLimit = $ redmineLimit ;
332+ $ remaininglimit -= $ redmineLimit ;
330333 } else {
331334 $ realLimit = $ remaininglimit ;
332335 $ remaininglimit = 0 ;
@@ -347,13 +350,13 @@ protected function retrieveData(string $endpoint, array $params = []): array
347350 // After the first request we know the total_count for this endpoint
348351 // so lets use the total_count to correct $requestedLimit to save us
349352 // 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
351354 if (isset ($ newDataSet ['total_count ' ]) && $ newDataSet ['total_count ' ] < $ requestedLimit ) {
352355 $ requestedLimit = $ remaininglimit = (int ) $ newDataSet ['total_count ' ];
353356
354- if ($ remaininglimit > 100 ) {
355- $ realLimit = 100 ;
356- $ remaininglimit -= 100 ;
357+ if ($ remaininglimit > $ redmineLimit ) {
358+ $ realLimit = $ redmineLimit ;
359+ $ remaininglimit -= $ redmineLimit ;
357360 } else {
358361 $ realLimit = $ remaininglimit ;
359362 $ remaininglimit = 0 ;
0 commit comments