summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-10-02 07:09:48 +0000
committeralecpl <alec@alec.pl>2008-10-02 07:09:48 +0000
commita2740628bb1dcfaa84d00ac05a80a92afdaffbd6 (patch)
treeb22e4df98923da3cc94d5d8bbde21e0aa525141c /program/include
parent4e9349d5e8865acacb7eb44225186f219a95ecf3 (diff)
- improved rcube_sess_gc() when enable_caching=false, also use join() once
Diffstat (limited to 'program/include')
-rw-r--r--program/include/session.inc48
1 files changed, 26 insertions, 22 deletions
diff --git a/program/include/session.inc b/program/include/session.inc
index f9b7f86a4..d6486a43a 100644
--- a/program/include/session.inc
+++ b/program/include/session.inc
@@ -128,36 +128,40 @@ function rcube_sess_gc($maxlifetime)
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'];
- }
-
- $caching = $rcmail->config->get('enable_caching');
+ $exp_sessions = array();
+ while ($sql_arr = $DB->fetch_assoc($sql_result)) {
+ $exp_sessions[] = $sql_arr['sess_id'];
+ }
- if (sizeof($exp_sessions)) {
- // delete session cache records
- if ($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 ('".join("','", $exp_sessions)."')");
+ WHERE session_id IN (" . $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;