From 007cd537d0cdffc1f2000cf2563f5046df9901fb Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Fri, 8 Feb 2013 08:04:23 +1300 Subject: [PATCH] MDL-37645 cache: fixed issue deleting mongo instance --- cache/stores/memcache/lib.php | 4 ++-- cache/stores/memcached/lib.php | 4 ++-- cache/stores/mongodb/lib.php | 8 +++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cache/stores/memcache/lib.php b/cache/stores/memcache/lib.php index e9c6e1d32b6..193f5c77082 100644 --- a/cache/stores/memcache/lib.php +++ b/cache/stores/memcache/lib.php @@ -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 +} diff --git a/cache/stores/memcached/lib.php b/cache/stores/memcached/lib.php index 4cad20cb72b..77d227561de 100644 --- a/cache/stores/memcached/lib.php +++ b/cache/stores/memcached/lib.php @@ -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 +} diff --git a/cache/stores/mongodb/lib.php b/cache/stores/mongodb/lib.php index 39a180683c7..7a5e6ec6a5c 100644 --- a/cache/stores/mongodb/lib.php +++ b/cache/stores/mongodb/lib.php @@ -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();