alecpl
2009-09-24 38bf4253fb6f67d655ea119ee97fff492e84177a
- Fix cache status checking + improve cache operations performance (#1486104)


2 files modified
40 ■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/include/rcube_imap.php 39 ●●●● patch | view | raw | blame | history
CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG RoundCube Webmail
===========================
- Fix cache status checking + improve cache operations performance (#1486104)
- Prevent from setting INBOX as any of special folders (#1486114)
- Fix regular expression for e-mail address (#1486152)
- Fix Received header format
program/include/rcube_imap.php
@@ -485,7 +485,6 @@
   */
  private function _messagecount($mailbox='', $mode='ALL', $force=FALSE)
    {
    $a_mailbox_cache = FALSE;
    $mode = strtoupper($mode);
    if (empty($mailbox))
@@ -2140,8 +2139,8 @@
   */
  function get_cache($key)
    {
    // read cache
    if (!isset($this->cache[$key]) && $this->caching_enabled)
    // read cache (if it was not read before)
    if (!count($this->cache) && $this->caching_enabled)
      {
      return $this->_read_cache_record($key);
      }
@@ -2218,7 +2217,8 @@
        {
    $sql_key = preg_replace('/^IMAP\./', '', $sql_arr['cache_key']);
        $this->cache_keys[$sql_key] = $sql_arr['cache_id'];
    $this->cache[$sql_key] = $sql_arr['data'] ? unserialize($sql_arr['data']) : FALSE;
    if (!isset($this->cache[$sql_key]))
      $this->cache[$sql_key] = $sql_arr['data'] ? unserialize($sql_arr['data']) : FALSE;
        }
      }
@@ -2232,23 +2232,6 @@
    {
    if (!$this->db)
      return FALSE;
    // check if we already have a cache entry for this key
    if (!isset($this->cache_keys[$key]))
      {
      $sql_result = $this->db->query(
        "SELECT cache_id
         FROM ".get_table_name('cache')."
         WHERE  user_id=?
         AND    cache_key=?",
        $_SESSION['user_id'],
        'IMAP.'.$key);
      if ($sql_arr = $this->db->fetch_assoc($sql_result))
        $this->cache_keys[$key] = $sql_arr['cache_id'];
      else
        $this->cache_keys[$key] = FALSE;
      }
    // update existing cache record
    if ($this->cache_keys[$key])
@@ -2272,6 +2255,18 @@
        $_SESSION['user_id'],
        'IMAP.'.$key,
        $data);
      // get cache entry ID for this key
      $sql_result = $this->db->query(
        "SELECT cache_id
         FROM ".get_table_name('cache')."
         WHERE  user_id=?
         AND    cache_key=?",
        $_SESSION['user_id'],
        'IMAP.'.$key);
        if ($sql_arr = $this->db->fetch_assoc($sql_result))
          $this->cache_keys[$key] = $sql_arr['cache_id'];
      }
    }
@@ -2286,6 +2281,8 @@
       AND    cache_key=?",
      $_SESSION['user_id'],
      'IMAP.'.$key);
    unset($this->cache_keys[$key]);
    }