[Svn] r1911 - trunk/roundcubemail/program/include

trac at roundcube.net trac at roundcube.net
Thu Oct 2 09:09:48 CEST 2008


Author: alec
Date: 2008-10-02 02:09:48 -0500 (Thu, 02 Oct 2008)
New Revision: 1911

Modified:
   trunk/roundcubemail/program/include/session.inc
Log:
- improved rcube_sess_gc() when enable_caching=false, also use join() once


Modified: trunk/roundcubemail/program/include/session.inc
===================================================================
--- trunk/roundcubemail/program/include/session.inc	2008-10-01 15:32:59 UTC (rev 1910)
+++ trunk/roundcubemail/program/include/session.inc	2008-10-02 07:09:48 UTC (rev 1911)
@@ -128,36 +128,40 @@
     return false;
   }
 
-  // get all expired sessions
-  $sql_result = $DB->query(
-    "SELECT sess_id
-     FROM " . get_table_name('session') . "
-     WHERE " . $DB->unixtimestamp($DB->now())."-".$DB->unixtimestamp('changed') . " > ?",
-    $maxlifetime);
+  if ($rcmail->config->get('enable_caching')) {
+    // get all expired sessions
+    $sql_result = $DB->query(
+	"SELECT sess_id
+        FROM " . get_table_name('session') . "
+        WHERE " . $DB->unixtimestamp($DB->now())."-".$DB->unixtimestamp('changed') . " > ?",
+	$maxlifetime);
                                    
-  $exp_sessions = array();
-  while ($sql_arr = $DB->fetch_assoc($sql_result)) {
-    $exp_sessions[] = $sql_arr['sess_id'];
-  }
+    $exp_sessions = array();
+    while ($sql_arr = $DB->fetch_assoc($sql_result)) {
+      $exp_sessions[] = $sql_arr['sess_id'];
+    }
 
-  $caching = $rcmail->config->get('enable_caching');
+    if (sizeof($exp_sessions)) {
+      $exp_sessions = "'" . join("','", $exp_sessions) . "'";
+      // delete session cache records
+      $DB->query("DELETE FROM " . get_table_name('cache') . "
+            WHERE session_id IN (" . $exp_sessions . ")");
 
-  if (sizeof($exp_sessions)) {
-    // delete session cache records
-    if ($caching) {
-      $DB->query("DELETE FROM " . get_table_name('cache') . "
-                  WHERE session_id IN ('".join("','", $exp_sessions)."')");
+      // delete session records
+      $DB->query("DELETE FROM " . get_table_name('session') . "
+            WHERE sess_id IN (" . $exp_sessions . ")");
     }
 
-    // delete session records
+    // also run message cache GC
+    rcmail_message_cache_gc();
+  
+  } else {
+    // just delete all expired sessions
     $DB->query("DELETE FROM " . get_table_name('session') . "
-                WHERE sess_id IN ('".join("','", $exp_sessions)."')");
+        WHERE " . $DB->unixtimestamp($DB->now())."-".$DB->unixtimestamp('changed') . " > ?",
+	$maxlifetime);
   }
 
-  // also run message cache GC
-  if ($caching) {
-    rcmail_message_cache_gc();
-  }
   rcmail_temp_gc();
 
   return true;

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



More information about the Svn mailing list