Permalink
Browse files

MDL-37645 cache: fixed issue deleting mongo instance

  • Loading branch information...
1 parent 8fd56c1 commit bb4c3916888bff112b8fad6666b7eb7b8975e813 Sam Hemelryk committed Feb 7, 2013
Showing with 11 additions and 5 deletions.
  1. +2 −2 cache/stores/memcache/lib.php
  2. +2 −2 cache/stores/memcached/lib.php
  3. +7 −1 cache/stores/mongodb/lib.php
@@ -339,7 +339,7 @@ public function instance_deleted() {
$connection->addServer($server[0], $server[1], true, $server[2]);
}
}
- $connection->flush();
+ @$connection->flush();
unset($connection);
unset($this->connection);
}
@@ -376,4 +376,4 @@ public static function initialise_test_instance(cache_definition $definition) {
public function my_name() {
return $this->name;
}
-}
+}
@@ -424,7 +424,7 @@ public function instance_deleted() {
$connection->addServers($this->servers);
}
}
- $connection->flush();
+ @$connection->flush();
unset($connection);
unset($this->connection);
}
@@ -477,4 +477,4 @@ public static function initialise_test_instance(cache_definition $definition) {
public function my_name() {
return $this->name;
}
-}
+}
@@ -463,7 +463,13 @@ public function instance_deleted() {
if ($this->connection) {
$connection = $this->connection;
} else {
- $connection = new Mongo($this->server, $this->options);
+ try {
+ $connection = new Mongo($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.
+ return;
+ }
}
$database = $connection->selectDB($this->databasename);
$database->drop();

0 comments on commit bb4c391

Please sign in to comment.