From d3853fc83ced060bf15c92e35a61e9893f983916 Mon Sep 17 00:00:00 2001 From: Ziaratban Date: Tue, 11 Feb 2020 11:04:02 +0330 Subject: [PATCH 1/2] fix each() start key foreach($cursor as $i => $v) exit($i); #return 1 -> bug ... --- src/BatchQueryResult.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BatchQueryResult.php b/src/BatchQueryResult.php index 23f268959..3600a9c1d 100644 --- a/src/BatchQueryResult.php +++ b/src/BatchQueryResult.php @@ -107,7 +107,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; } From c3b8d8bfd9ed74ccc7c35505e3dc0eb36f205506 Mon Sep 17 00:00:00 2001 From: Ziaratban Date: Thu, 20 Feb 2020 10:26:16 +0330 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2d14a042..8ad015eac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ Yii Framework 2 mongodb extension Change Log ============================================ +2.2.0 under development +------------------------ + +- Bug #297 : Fixed zero-index key problem in `ActiveQuery::Each()` (ziaratban) + + 2.1.10 under development ------------------------