From 29c64b0bdd3ee16532ed5f390044e5d5bec5bdec Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sun, 23 Nov 2008 08:24:49 -0500
Subject: [PATCH] Also clean cache table when removing old messages from cache

---
 program/include/main.inc |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/program/include/main.inc b/program/include/main.inc
index e531bd8..b5447c7 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -151,19 +151,19 @@
  * Garbage collector for cache entries.
  * Remove all expired message cache records
  */
-function rcmail_message_cache_gc()
+function rcmail_cache_gc()
   {
-  global $DB, $CONFIG;
-  
-  // no cache lifetime configured
-  if (empty($CONFIG['message_cache_lifetime']))
-    return;
+  $rcmail = rcmail::get_instance();
+  $db = $rcmail->get_dbh();
   
   // get target timestamp
-  $ts = get_offset_time($CONFIG['message_cache_lifetime'], -1);
+  $ts = get_offset_time($rcmail->config->get('message_cache_lifetime', '30d'), -1);
   
-  $DB->query("DELETE FROM ".get_table_name('messages')."
-             WHERE  created < ".$DB->fromunixtime($ts));
+  $db->query("DELETE FROM ".get_table_name('messages')."
+             WHERE  created < " . $db->fromunixtime($ts));
+
+  $db->query("DELETE FROM ".get_table_name('cache')."
+              WHERE  created < " . $db->fromunixtime($ts));
   }
 
 

--
Gitblit v1.9.1