From: Chuck Hagenbuch Date: Mon, 24 Jan 2011 03:59:04 +0000 (-0500) Subject: DB may have been closed before write() - reconnect if it's not active X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=abc20536a649e6810bac38369ab3a83a5eb95f26;p=horde.git DB may have been closed before write() - reconnect if it's not active --- diff --git a/framework/SessionHandler/lib/Horde/SessionHandler/Storage/Sql.php b/framework/SessionHandler/lib/Horde/SessionHandler/Storage/Sql.php index 39cda3c69..281cb3300 100644 --- a/framework/SessionHandler/lib/Horde/SessionHandler/Storage/Sql.php +++ b/framework/SessionHandler/lib/Horde/SessionHandler/Storage/Sql.php @@ -72,11 +72,14 @@ class Horde_SessionHandler_Storage_Sql extends Horde_SessionHandler_Storage public function close() { /* Close any open transactions. */ - try { - $this->_db->commitDbTransaction(); - } catch (Horde_Db_Exception $e) { - throw new Horde_SessionHandler_Exception($e); + if ($this->_db->transactionStarted()) { + try { + $this->_db->commitDbTransaction(); + } catch (Horde_Db_Exception $e) { + return false; + } } + return true; } /** @@ -104,6 +107,8 @@ class Horde_SessionHandler_Storage_Sql extends Horde_SessionHandler_Storage */ public function write($id, $session_data) { + if (!$this->_db->isActive()) { $this->_db->reconnect(); } + /* Build the SQL query. */ $query = sprintf('SELECT session_id FROM %s WHERE session_id = ?', $this->_params['table']);