Changeset 5302 in subversion


Ignore:
Timestamp:
Oct 3, 2011 9:13:44 AM (20 months ago)
Author:
alec
Message:
  • Improved performance of draft saving by usage of APPENDUID response if available (skipped SEARCH call)
Location:
trunk/roundcubemail/program
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/rcube_imap.php

    r5297 r5302  
    25322532     * @param boolean $is_file True if $message is a filename 
    25332533     * 
    2534      * @return boolean True on success, False on error 
     2534     * @return int|bool Appended message UID or True on success, False on error 
    25352535     */ 
    25362536    function save_message($mailbox, &$message, $headers='', $is_file=false) 
  • trunk/roundcubemail/program/include/rcube_imap_generic.php

    r5240 r5302  
    311311                else { 
    312312                    $this->resultcode = null; 
     313                    // parse response for [APPENDUID 1204196876 3456] 
     314                    if (preg_match("/^\[APPENDUID [0-9]+ ([0-9,:*]+)\]/i", $str, $m)) { 
     315                        $this->data['APPENDUID'] = $m[1]; 
     316                    } 
    313317                } 
    314318                $this->result = $str; 
     
    24992503    } 
    25002504 
     2505    /** 
     2506     * Handler for IMAP APPEND command 
     2507     * 
     2508     * @param string $mailbox Mailbox name 
     2509     * @param string $message Message content 
     2510     * 
     2511     * @return string|bool On success APPENDUID response (if available) or True, False on failure 
     2512     */ 
    25012513    function append($mailbox, &$message) 
    25022514    { 
     2515        unset($this->data['APPENDUID']); 
     2516 
    25032517        if (!$mailbox) { 
    25042518            return false; 
     
    25392553            unset($this->data['STATUS:'.$mailbox]); 
    25402554 
    2541             return ($this->parseResult($line, 'APPEND: ') == self::ERROR_OK); 
     2555            if ($this->parseResult($line, 'APPEND: ') != self::ERROR_OK) 
     2556                return false; 
     2557            else if (!empty($this->data['APPENDUID'])) 
     2558                return $this->data['APPENDUID']; 
     2559            else 
     2560                return true; 
    25422561        } 
    25432562        else { 
     
    25482567    } 
    25492568 
     2569    /** 
     2570     * Handler for IMAP APPEND command. 
     2571     * 
     2572     * @param string $mailbox Mailbox name 
     2573     * @param string $path    Path to the file with message body 
     2574     * @param string $headers Message headers 
     2575     * 
     2576     * @return string|bool On success APPENDUID response (if available) or True, False on failure 
     2577     */ 
    25502578    function appendFromFile($mailbox, $path, $headers=null) 
    25512579    { 
     2580        unset($this->data['APPENDUID']); 
     2581 
    25522582        if (!$mailbox) { 
    25532583            return false; 
     
    26162646            unset($this->data['STATUS:'.$mailbox]); 
    26172647 
    2618             return ($this->parseResult($line, 'APPEND: ') == self::ERROR_OK); 
     2648            if ($this->parseResult($line, 'APPEND: ') != self::ERROR_OK) 
     2649                return false; 
     2650            else if (!empty($this->data['APPENDUID'])) 
     2651                return $this->data['APPENDUID']; 
     2652            else 
     2653                return true; 
    26192654        } 
    26202655        else { 
  • trunk/roundcubemail/program/steps/mail/sendmail.inc

    r5301 r5302  
    625625  if (!empty($CONFIG['sendmail_delay'])) 
    626626    $RCMAIL->user->save_prefs(array('last_message_time' => time())); 
    627    
     627 
    628628  // set replied/forwarded flag 
    629629  if ($_SESSION['compose']['reply_uid']) 
     
    701701  if ($olddraftmessageid) { 
    702702    // delete previous saved draft 
     703    // @TODO: use message UID (remember to check UIDVALIDITY) to skip this SEARCH 
    703704    $a_deleteid = $IMAP->search_once($CONFIG['drafts_mbox'], 
    704705        'HEADER Message-ID '.$olddraftmessageid, true); 
     
    724725  $msgid = strtr($message_id, array('>' => '', '<' => '')); 
    725726 
    726   // remember new draft-uid 
    727   $draftuids = $IMAP->search_once($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid, true); 
    728   $_SESSION['compose']['param']['draft_uid'] = $draftuids[0]; 
     727  // remember new draft-uid ($saved could be an UID or TRUE here) 
     728  if (is_bool($saved)) { 
     729    $draftuids = $IMAP->search_once($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid, true); 
     730    $saved     = $draftuids[0]; 
     731  } 
     732  $_SESSION['compose']['param']['draft_uid'] = $saved; 
    729733 
    730734  // display success 
Note: See TracChangeset for help on using the changeset viewer.