Skip to content

Commit

Permalink
Fix #379: Fix method getId option to match changes in MongoDB 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Radeox authored Oct 3, 2024
1 parent 6a9d4cb commit f48687b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Yii Framework 2 mongodb extension Change Log
-----------------------

- Bug #373: Fix generator `trim` validator and `strtolower` causes exception in PHP 8.1 (dorkdomain)
- Bug #379: Fix method `getId` option to match changes in MongoDB 1.20 (radeox)

3.0.1 May 22, 2023
------------------
Expand Down
10 changes: 9 additions & 1 deletion src/Query.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
Expand Down Expand Up @@ -212,7 +213,14 @@ public function buildCursor($db = null)
*/
protected function fetchRows($cursor, $all = true, $indexBy = null)
{
$token = 'fetch cursor id = ' . $cursor->getId();
try {
# MongoDB >= 1.20
$token = 'fetch cursor id = ' . $cursor->getId(true);
} catch (\ArgumentCountError $e) {
# MongoDB < 1.20
$token = 'fetch cursor id = ' . $cursor->getId();
}

Yii::info($token, __METHOD__);
try {
Yii::beginProfile($token, __METHOD__);
Expand Down

0 comments on commit f48687b

Please sign in to comment.