diff --git a/CHANGELOG.md b/CHANGELOG.md index ec3c041ac..49e7d1dc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Yii Framework 2 mongodb extension Change Log - Enh #294: Add transactions support (ziaratban) - Bug #299: Drop limit of `batchSize` cursor option in application level according to [jira.mongodb(PHP-457)](https://jira.mongodb.org/browse/PHP-457) (ziaratban) +- Bug #297: Fixed zero-index key problem in `ActiveQuery::Each()` (ziaratban) 2.1.12 August 09, 2021 diff --git a/src/BatchQueryResult.php b/src/BatchQueryResult.php index 39a458575..0f568c4fd 100644 --- a/src/BatchQueryResult.php +++ b/src/BatchQueryResult.php @@ -110,7 +110,7 @@ public function next() if ($this->query->indexBy !== null) { $this->_key = key($this->_batch); } elseif (key($this->_batch) !== null) { - $this->_key++; + $this->_key = $this->_key === null ? 0 : $this->_key + 1; } else { $this->_key = null; }