[Svn] r2463 - in trunk/roundcubemail: . program/include

trac at roundcube.net trac at roundcube.net
Sat May 9 22:07:11 CEST 2009


Author: alec
Date: 2009-05-09 15:07:10 -0500 (Sat, 09 May 2009)
New Revision: 2463

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/include/rcube_mdb2.php
   trunk/roundcubemail/program/include/session.inc
Log:
- Fix session handling on non-session SQL query error (#1485734)


Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2009-05-09 16:35:20 UTC (rev 2462)
+++ trunk/roundcubemail/CHANGELOG	2009-05-09 20:07:10 UTC (rev 2463)
@@ -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)

Modified: trunk/roundcubemail/program/include/rcube_mdb2.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_mdb2.php	2009-05-09 16:35:20 UTC (rev 2462)
+++ trunk/roundcubemail/program/include/rcube_mdb2.php	2009-05-09 20:07:10 UTC (rev 2463)
@@ -178,6 +178,17 @@
     
 
   /**
+   * 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 @@
    */
   function query()
     {
+    if (!$this->is_connected())
+      return NULL;
+    
     $params = func_get_args();
     $query = array_shift($params);
 
@@ -360,7 +374,7 @@
    */
   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);

Modified: trunk/roundcubemail/program/include/session.inc
===================================================================
--- trunk/roundcubemail/program/include/session.inc	2009-05-09 16:35:20 UTC (rev 2462)
+++ trunk/roundcubemail/program/include/session.inc	2009-05-09 20:07:10 UTC (rev 2463)
@@ -39,10 +39,6 @@
   
   $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 @@
 {
   $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 @@
   $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 @@
   $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));

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list