MDL-37645 cache: fixed issue deleting mongo instance
authorSam Hemelryk <sam@moodle.com>
Thu, 7 Feb 2013 19:04:23 +0000 (08:04 +1300)
committerSam Hemelryk <sam@moodle.com>
Thu, 7 Feb 2013 19:06:21 +0000 (08:06 +1300)
cache/stores/memcache/lib.php
cache/stores/memcached/lib.php
cache/stores/mongodb/lib.php

index e9c6e1d..193f5c7 100644 (file)
@@ -339,7 +339,7 @@ class cachestore_memcache extends cache_store implements cache_is_configurable {
                 $connection->addServer($server[0], $server[1], true, $server[2]);
             }
         }
-        $connection->flush();
+        @$connection->flush();
         unset($connection);
         unset($this->connection);
     }
@@ -376,4 +376,4 @@ class cachestore_memcache extends cache_store implements cache_is_configurable {
     public function my_name() {
         return $this->name;
     }
-}
\ No newline at end of file
+}
index 4cad20c..77d2275 100644 (file)
@@ -424,7 +424,7 @@ class cachestore_memcached extends cache_store implements cache_is_configurable
                 $connection->addServers($this->servers);
             }
         }
-        $connection->flush();
+        @$connection->flush();
         unset($connection);
         unset($this->connection);
     }
@@ -477,4 +477,4 @@ class cachestore_memcached extends cache_store implements cache_is_configurable
     public function my_name() {
         return $this->name;
     }
-}
\ No newline at end of file
+}
index 39a1806..7a5e6ec 100644 (file)
@@ -463,7 +463,13 @@ class cachestore_mongodb extends cache_store implements cache_is_configurable {
         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();