From 76e499e8a1760d1c519a228e13dfdb69fd4c38f7 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Wed, 16 May 2012 09:00:23 -0400
Subject: [PATCH] Also accept PHP exceptions as argument to rcube::raise_error()

---
 program/include/rcube_cache.php |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/program/include/rcube_cache.php b/program/include/rcube_cache.php
index 3e6bc0f..ef04beb 100644
--- a/program/include/rcube_cache.php
+++ b/program/include/rcube_cache.php
@@ -59,19 +59,19 @@
      * @param string $type   Engine type ('db' or 'memcache' or 'apc')
      * @param int    $userid User identifier
      * @param string $prefix Key name prefix
-     * @param int    $ttl    Expiration time of memcache/apc items in seconds (max.2592000)
+     * @param string $ttl    Expiration time of memcache/apc items
      * @param bool   $packed Enables/disabled data serialization.
      *                       It's possible to disable data serialization if you're sure
      *                       stored data will be always a safe string
      */
     function __construct($type, $userid, $prefix='', $ttl=0, $packed=true)
     {
-        $rcmail = rcube::get_instance();
-        $type   = strtolower($type);
+        $rcube = rcube::get_instance();
+        $type  = strtolower($type);
 
         if ($type == 'memcache') {
             $this->type = 'memcache';
-            $this->db   = $rcmail->get_memcache();
+            $this->db   = $rcube->get_memcache();
         }
         else if ($type == 'apc') {
             $this->type = 'apc';
@@ -79,11 +79,15 @@
         }
         else {
             $this->type = 'db';
-            $this->db   = $rcmail->get_dbh();
+            $this->db   = $rcube->get_dbh();
         }
 
+        // convert ttl string to seconds
+        $ttl = get_offset_sec($ttl);
+        if ($ttl > 2592000) $ttl = 2592000;
+
         $this->userid    = (int) $userid;
-        $this->ttl       = (int) $ttl;
+        $this->ttl       = $ttl;
         $this->packed    = $packed;
         $this->prefix    = $prefix;
     }

--
Gitblit v1.9.1