diff --git a/CHANGELOG.md b/CHANGELOG.md index a69acb95f..a9a4df3f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ Yii Framework 2 redis extension Change Log ----------------------- - Chg #14: Added missing `BLPOP` to `$redisCommands` (samdark) - +- Bug #37 when redis connection is down (mirocow) 2.0.4 May 10, 2015 ------------------ diff --git a/Connection.php b/Connection.php index a004d4a1b..91f6fb2f2 100644 --- a/Connection.php +++ b/Connection.php @@ -225,7 +225,7 @@ class Connection extends Component /** * @var resource redis socket connection */ - private $_socket; + private $_socket = false; /** @@ -245,7 +245,7 @@ public function __sleep() */ public function getIsActive() { - return $this->_socket !== null; + return $this->_socket !== false; } /** @@ -255,7 +255,7 @@ public function getIsActive() */ public function open() { - if ($this->_socket !== null) { + if ($this->_socket !== false) { return; } $connection = ($this->unixSocket ?: $this->hostname . ':' . $this->port) . ', database=' . $this->database; @@ -288,7 +288,7 @@ public function open() */ public function close() { - if ($this->_socket !== null) { + if ($this->_socket !== false) { $connection = ($this->unixSocket ?: $this->hostname . ':' . $this->port) . ', database=' . $this->database; \Yii::trace('Closing DB connection: ' . $connection, __METHOD__); $this->executeCommand('QUIT');