Skip to content

Commit

Permalink
Fix getId for older versions of MongoDB
Browse files Browse the repository at this point in the history
  • Loading branch information
Radeox committed Oct 2, 2024
1 parent 49bba98 commit 59270e0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,14 @@ public function buildCursor($db = null)
*/
protected function fetchRows($cursor, $all = true, $indexBy = null)
{
$token = 'fetch cursor id = ' . $cursor->getId(true);
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 59270e0

Please sign in to comment.