Skip to content
Permalink
Browse files

Check $_connection is not null before trying to use it

Stops a fatal error if calling isConnected() after disconnect().
  • Loading branch information...
graemetait committed Sep 21, 2015
1 parent 8fae10a commit 1b33efaad3b3e9af87074552127839375d3cedee
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/Cake/Model/Datasource/DboSource.php
@@ -857,10 +857,14 @@ public function name($data) {
* @return bool True if the database is connected, else false
*/
public function isConnected() {
try {
$connected = $this->_connection->query('SELECT 1');
} catch (Exception $e) {
if (is_null($this->_connection)) {
$connected = false;
} else {
try {
$connected = $this->_connection->query('SELECT 1');
} catch (Exception $e) {
$connected = false;
}
}
$this->connected = ! empty($connected);
return $this->connected;

0 comments on commit 1b33efa

Please sign in to comment.
You can’t perform that action at this time.