summaryrefslogtreecommitdiff
path: root/vendor/aws/aws-sdk-php/src/ResultPaginator.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/aws/aws-sdk-php/src/ResultPaginator.php')
-rw-r--r--vendor/aws/aws-sdk-php/src/ResultPaginator.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/vendor/aws/aws-sdk-php/src/ResultPaginator.php b/vendor/aws/aws-sdk-php/src/ResultPaginator.php
index 2c5ec5c..2b0c7c9 100644
--- a/vendor/aws/aws-sdk-php/src/ResultPaginator.php
+++ b/vendor/aws/aws-sdk-php/src/ResultPaginator.php
@@ -127,10 +127,26 @@ class ResultPaginator implements \Iterator
}
if ($this->nextToken || !$this->requestCount) {
+ //Forward/backward paging can result in a case where the last page's nextforwardtoken
+ //is the same as the one that came before it. This can cause an infinite loop.
+ $hasBidirectionalPaging = $this->config['output_token'] === 'nextForwardToken';
+ if ($hasBidirectionalPaging && $this->nextToken) {
+ $tokenKey = $this->config['input_token'];
+ $previousToken = $this->nextToken[$tokenKey];
+ }
+
$this->result = $this->client->execute(
$this->createNextCommand($this->args, $this->nextToken)
);
+
$this->nextToken = $this->determineNextToken($this->result);
+
+ if (isset($previousToken)
+ && $previousToken === $this->nextToken[$tokenKey]
+ ) {
+ return false;
+ }
+
$this->requestCount++;
return true;
}