Changeset 40a1860 in github


Ignore:
Timestamp:
May 23, 2011 7:03:52 AM (2 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
c9f4e9b
Parents:
7ad8e2c
Message:
  • Store user preferences in session when write-master is not available and session is stored in memcache, write them later
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r3e48b941 r40a1860  
    22=========================== 
    33 
     4- Store user preferences in session when write-master is not available and session is stored in memcache, write them later 
    45- Improve performence of folder manager operations 
    56- Fix default_port option handling in Installer when config.inc.php file exists (#1487925) 
  • program/include/rcmail.php

    r7ad8e2c r40a1860  
    11261126      $this->imap->expunge('INBOX'); 
    11271127    } 
     1128 
     1129    // Try to save unsaved user preferences 
     1130    if (!empty($_SESSION['preferences'])) { 
     1131      $this->user->save_prefs(unserialize($_SESSION['preferences'])); 
     1132    } 
    11281133  } 
    11291134 
  • program/include/rcube_user.php

    r80809d6 r40a1860  
    3030class rcube_user 
    3131{ 
    32     public $ID = null; 
    33     public $data = null; 
    34     public $language = null; 
     32    public $ID; 
     33    public $data; 
     34    public $language; 
    3535 
    3636    /** 
     
    3939     * @var rcube_mdb2 
    4040     */ 
    41     private $db = null; 
     41    private $db; 
     42 
     43    /** 
     44     * rcmail object. 
     45     * 
     46     * @var rcmail 
     47     */ 
     48    private $rc; 
    4249 
    4350 
     
    5057    function __construct($id = null, $sql_arr = null) 
    5158    { 
    52         $this->db = rcmail::get_instance()->get_dbh(); 
     59        $this->rc = rcmail::get_instance(); 
     60        $this->db = $this->rc->get_dbh(); 
    5361 
    5462        if ($id && !$sql_arr) { 
     
    8391            // if no domain was provided... 
    8492            if (empty($domain)) { 
    85                 $rcmail = rcmail::get_instance(); 
    86                 $domain = $rcmail->config->mail_domain($this->data['mail_host']); 
     93                $domain = $this->rc->config->mail_domain($this->data['mail_host']); 
    8794            } 
    8895 
     
    111118            $prefs = array('language' => $this->language); 
    112119 
    113         if ($this->ID && $this->data['preferences']) 
    114             $prefs += (array)unserialize($this->data['preferences']); 
     120        if ($this->ID) { 
     121            // Preferences from session (write-master is unavailable) 
     122            if (!empty($_SESSION['preferences'])) { 
     123                // Check last write attempt time, try to write again (every 5 minutes) 
     124                if ($_SESSION['preferences_time'] < time() - 5 * 60) { 
     125                    $this->save_prefs(unserialize($_SESSION['preferences'])); 
     126                } 
     127                else { 
     128                    $this->data['preferences'] = $_SESSION['preferences']; 
     129                } 
     130            } 
     131 
     132            if ($this->data['preferences']) { 
     133                $prefs += (array)unserialize($this->data['preferences']); 
     134            } 
     135        } 
    115136 
    116137        return $prefs; 
     
    129150            return false; 
    130151 
    131         $config = rcmail::get_instance()->config; 
     152        $config    = $this->rc->config; 
    132153        $old_prefs = (array)$this->get_prefs(); 
    133154 
     
    155176        $this->language = $_SESSION['language']; 
    156177 
     178        // Update success 
    157179        if ($this->db->affected_rows() !== false) { 
    158180            $config->set_user_prefs($a_user_prefs); 
    159181            $this->data['preferences'] = $save_prefs; 
     182 
     183            if (isset($_SESSION['preferences'])) { 
     184                $this->rc->session->remove('preferences'); 
     185                $this->rc->session->remove('preferences_time'); 
     186            } 
    160187            return true; 
     188        } 
     189        // Update error, but we are using replication (we have read-only DB connection) 
     190        // and we are storing session not in the SQL database 
     191        // we can store preferences in session and try to write later (see get_prefs()) 
     192        else if ($this->db->is_replicated() && $config->get('session_storage', 'db') != 'db') { 
     193            $_SESSION['preferences'] = $save_prefs; 
     194            $_SESSION['preferences_time'] = time(); 
     195            $config->set_user_prefs($a_user_prefs); 
     196            $this->data['preferences'] = $save_prefs; 
    161197        } 
    162198 
  • program/steps/mail/show.inc

    ra509bb6 r40a1860  
    6565  if ($MESSAGE->headers->others['list-post']) 
    6666    $OUTPUT->set_env('list_post', true); 
    67   if ($CONFIG['forward_attachment'])                                                                                                       
     67  if ($CONFIG['forward_attachment']) 
    6868    $OUTPUT->set_env('forward_attachment', true); 
    6969 
Note: See TracChangeset for help on using the changeset viewer.