Reputation: 1063
Our application is running on a (very) old MongoDB 2.4 cluster - for now, it's not possible to upgrade it to newer versions.
We were working on upgrading our application from PHP 5.6 to PHP7, everything was going fine until the version 1.4.0 of the mongodb driver deprecated MongoDB 2.4 support.
Since we need to support 2.4
, I tried to rollback the driver version to 1.3.0
and 1.3.2
and both of them are throwing this error:
Call to undefined method MongoDB\Driver\Server::executeReadCommand()
This executeReadCommand()
seems to be something from 1.4.0
, but how can that be if I'm using the version 1.3.0
? Am I missing something?
PHP Configuration:
PHP 7.1.12 (cli) (built: Dec 1 2017 01:55:23) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.12, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
Mongo Driver Configuration:
root@6f40fb118d2d:/var/www/app# php --ri mongodb | grep version
MongoDB extension version => 1.3.0
libbson bundled version => 1.8.0
libmongoc bundled version => 1.8.0
Upvotes: 2
Views: 1732
Reputation: 6238
You should check if the mongo db extension is installed and available. Install it with pecl:
// Old version
sudo pecl install mongo
// New version
sudo pecl install mongodb
You should add "extension=mongodb.so" to php.ini
Upvotes: 0
Reputation: 1063
Well, of course, there's something missing!
Right after posting this I noticed that I completely forgot to declare the version of mongodb/mongodb
inside composer.json
, so composer was downloading always the latest version of the library, which is 1.3.0
.
mongodb/mongodb
also deprecated support to 2.4
in their 1.3.0 release.
I was able to fix the issue by locking the version of mongodb\mongodb
to 1.2.0
in composer.json
:
"mongodb/mongodb": "1.2.0"
Hope this helps someone that might be facing the same issue.
Cheers
Upvotes: 3