-
Bug
-
Resolution: Fixed
-
Minor
-
2.5.5, 2.6.2, 2.7
-
MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
-
MOODLE_25_STABLE, MOODLE_26_STABLE
-
45412-27
-
Trying to get 100% unit test completion here before Moodle 2.7, it was detected that we are using some deprecated stuff in the mongodb cache store.
Note that those deprecated uses continue working and they are not a problem for normal use, but they are a problem for getting unit tests passing (because of the PHP Warning they produce).
Looking for information, it seems the change happened in 2012... so perhaps it would be the time to change our store too:
http://derickrethans.nl/mongoclient.html
Just for reference, and in order to pass unit tests, I've applied here these quick changes (sure there are more, just to show the minimum I needed to get them passing without any warning):
index cdf764f..f7acf8c 100644
|
--- a/cache/stores/mongodb/lib.php
|
+++ b/cache/stores/mongodb/lib.php
|
@@ -141,7 +141,7 @@ class cachestore_mongodb extends cache_store implements cache_is_configurable {
|
}
|
|
try {
|
- $this->connection = new Mongo($this->server, $this->options);
|
+ $this->connection = new MongoClient($this->server, $this->options);
|
$this->isready = true;
|
} catch (MongoConnectionException $e) {
|
// We only want to catch MongoConnectionExceptions here.
|
@@ -303,7 +303,6 @@ class cachestore_mongodb extends cache_store implements cache_is_configurable {
|
$record['data'] = serialize($data);
|
$options = array(
|
'upsert' => true,
|
- 'safe' => $this->usesafe,
|
'w' => $this->usesafe ? 1 : 0
|
);
|
$this->delete($key);
|
@@ -356,7 +355,6 @@ class cachestore_mongodb extends cache_store implements cache_is_configurable {
|
}
|
$options = array(
|
'justOne' => false,
|
- 'safe' => $this->usesafe,
|
'w' => $this->usesafe ? 1 : 0
|
);
|
$result = $this->collection->remove($criteria, $options);
|
@@ -483,7 +481,7 @@ class cachestore_mongodb extends cache_store implements cache_is_configurable {
|
$connection = $this->connection;
|
} else {
|
try {
|
- $connection = new Mongo($this->server, $this->options);
|
+ $connection = new MongoClient($this->server, $this->options);
|
} catch (MongoConnectionException $e) {
|
// We only want to catch MongoConnectionExceptions here.
|
// If the server cannot be connected to we cannot clean it.
|
Basically Mongo() goes to MongoClient() and the 'safe' option is out (with 'w' getting the baton/changed its default).
Ciao
- blocks
-
MDLSITE-2356 Reduce the skipped tests in CI servers
-
- Closed
-
- has been marked as being related by
-
MDL-54592 Upgrade MongoDB cache store to use new library to be compatible with php7
-
- Closed
-