diff options
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | program/include/rcube_mdb2.php | 16 | ||||
-rw-r--r-- | program/include/session.inc | 16 |
3 files changed, 16 insertions, 17 deletions
@@ -1,6 +1,7 @@ CHANGELOG RoundCube Webmail =========================== +- Fix session handling on non-session SQL query error (#1485734) - Fix html editor mode setting when reopening draft message (#1485834) - Added quick search box menu (#1484304) - Fix wrong column sort order icons (#1485823) diff --git a/program/include/rcube_mdb2.php b/program/include/rcube_mdb2.php index 713ff4255..b1e5fff80 100644 --- a/program/include/rcube_mdb2.php +++ b/program/include/rcube_mdb2.php @@ -178,6 +178,17 @@ class rcube_mdb2 /** + * Connection state checker + * + * @param boolean True if in connected state + */ + function is_connected() + { + return PEAR::isError($this->db_handle) ? false : true; + } + + + /** * Execute a SQL query * * @param string SQL query to execute @@ -187,6 +198,9 @@ class rcube_mdb2 */ function query() { + if (!$this->is_connected()) + return NULL; + $params = func_get_args(); $query = array_shift($params); @@ -360,7 +374,7 @@ class rcube_mdb2 */ function _fetch_row($result, $mode) { - if ($result === FALSE || PEAR::isError($result)) + if ($result === FALSE || PEAR::isError($result) || !$this->is_connected()) return FALSE; return $result->fetchRow($mode); diff --git a/program/include/session.inc b/program/include/session.inc index 983d01587..d75b303b3 100644 --- a/program/include/session.inc +++ b/program/include/session.inc @@ -39,10 +39,6 @@ function rcube_sess_read($key) $DB = rcmail::get_instance()->get_dbh(); - if ($DB->is_error()) { - return false; - } - $sql_result = $DB->query( "SELECT vars, ip, " . $DB->unixtimestamp('changed') . " AS changed FROM " . get_table_name('session') . " @@ -66,10 +62,6 @@ function rcube_sess_write($key, $vars) { $DB = rcmail::get_instance()->get_dbh(); - if ($DB->is_error()) { - return false; - } - $sql_result = $DB->query( "SELECT 1 FROM " . get_table_name('session') . " WHERE sess_id=?", @@ -105,10 +97,6 @@ function rcube_sess_destroy($key) $rcmail = rcmail::get_instance(); $DB = $rcmail->get_dbh(); - if ($DB->is_error()) { - return false; - } - $DB->query("DELETE FROM " . get_table_name('session') . " WHERE sess_id=?", $key); return true; @@ -121,10 +109,6 @@ function rcube_sess_gc($maxlifetime) $rcmail = rcmail::get_instance(); $DB = $rcmail->get_dbh(); - if ($DB->is_error()) { - return false; - } - // just delete all expired sessions $DB->query("DELETE FROM " . get_table_name('session') . " WHERE changed < " . $DB->fromunixtime(time() - $maxlifetime)); |