-
-
Notifications
You must be signed in to change notification settings - Fork 191
Description
i again get the error
MongoDB\Driver\Cursor::getId(): The method "MongoDB\Driver\Cursor::getId" will no longer return a "MongoDB\Driver\CursorId" instance in the future. Pass "true" as argument to change to the new behavior and receive a "MongoDB\BSON\Int64" instance instead.
getId in fetchAll needs that true param, not?
https://github.com/yiisoft/yii2-mongodb/blob/master/src/Query.php#L215
I have to admit, i am total not sure what really is the problem: the yii2 library, my mongodb extension or the mongodb version, which are all up to date (afaik). So i started asking AI:
What AI Discovered (no idea whether this could be true π ):
Version 3.0.3 (May 06, 2025):
Bug #379, #382: Fixed usage of getId method in BatchQueryResult and Cursor classes to match changes in MongoDB PHP Extension 1.20.1
Version 3.0.4 (October 08, 2025) - THIS IS YOUR VERSION:
Bug #388: Fix MongoDB\Driver\Cursor::getId() expects exactly 0 arguments, 1 given
The Problem
They introduced a fix in 3.0.3, but then they BROKE it again in 3.0.4!
In version 3.0.3, they added getId(true) to fix the deprecation warning for MongoDB extension 1.20.1.
But then in version 3.0.4 (released 5 days ago), they "fixed" it back to getId() because passing an argument causes an error in older versions of the MongoDB extension.
The Issue:
- MongoDB PHP Extension 1.20.1 (what you have) introduced the deprecation warning and wants getId(true)
- Yii2-MongoDB 3.0.4 removed the true parameter to support older MongoDB extensions
- You're stuck with the deprecation warning because the library is trying to be backwards compatible
Your Options:
β
Option 1: Ignore the Warning (RECOMMENDED)
This is just a deprecation notice. Your code works perfectly fine. The warning is there to prepare you for a future breaking change, but it won't affect functionality until MongoDB extension 2.0.
β
Option 2: Pin to Yii2-MongoDB 3.0.3
The version that had the fix: