问题
I've updated my MongoDB to the 3.6 version. I'm using a PHP MongoClient on CentOS 7 and PHP 5.5.38. If I run the aggregateCursor method of the MongoDB library, through the first example reported in http://php.net/manual/en/mongocollection.aggregatecursor.php, I obtain the following error message as below:
PHP Fatal error: Uncaught exception 'MongoCursorException' with message '95.110.150.99:27017: the command cursor did not return a correctly structured response'
Do you have any idea about this behaviour?
回答1:
The problem was in the cursor id returned by Mongo:
["id"]=>
float(6.43105103109E+18)
To build the MongoCommandCursor object, the id is expected to be a MongoInt64:
["id"]=>
object(MongoInt64)#5 (1) {
["value"]=>
string(12) "392143983421"
}
It can be done by setting:
ini_set('mongo.native_long', false);
ini_set('mongo.long_as_object', true);
The problem is described in details at: https://derickrethans.nl/64bit-ints-in-mongodb.html
来源:https://stackoverflow.com/questions/47569871/aggregatecursor-issue-with-mongodb-3-6