DboSource now check the actual status of connection by executing a dumb query on DB

This change makes it possible for developer to build reconnection logic
on MySQL connections which frequently time out in long running CLI
processes.

Cherry picked onto 2.7 from #7190.
This commit is contained in:
paolo 2015-08-06 16:05:16 +02:00 committed by mark_story
parent f959b76013
commit a7b5f8c3af

View file

@ -857,6 +857,12 @@ class DboSource extends DataSource {
* @return bool True if the database is connected, else false * @return bool True if the database is connected, else false
*/ */
public function isConnected() { public function isConnected() {
try {
$connected = $this->_connection->query('SELECT 1');
} catch (Exception $e) {
$connected = false;
}
$this->connected = ! empty($connected);
return $this->connected; return $this->connected;
} }