Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #379: Fix method getId option to match changes in MongoDB 1.20 #380

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading