[Svn] r3446 - in trunk/roundcubemail/program: include steps/mail

trac at roundcube.net trac at roundcube.net
Wed Mar 31 09:14:32 CEST 2010


Author: alec
Date: 2010-03-31 02:14:32 -0500 (Wed, 31 Mar 2010)
New Revision: 3446

Modified:
   trunk/roundcubemail/program/include/rcube_imap.php
   trunk/roundcubemail/program/include/rcube_imap_generic.php
   trunk/roundcubemail/program/steps/mail/sendmail.inc
Log:
- fix save/delete draft message with enabled threading (#1486596)
- performance improvement using UID SEARCH intead of SEARCH + FETCH
- re-fix r3445


Modified: trunk/roundcubemail/program/include/rcube_imap.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_imap.php	2010-03-31 06:25:23 UTC (rev 3445)
+++ trunk/roundcubemail/program/include/rcube_imap.php	2010-03-31 07:14:32 UTC (rev 3446)
@@ -1414,6 +1414,27 @@
         return $a_messages;
     }
     
+
+    /**
+     * Direct (real and simple) SEARCH request to IMAP server,
+     * without result sorting and caching
+     *
+     * @param  string  Mailbox name to search in
+     * @param  string  Search string
+     * @param  boolean True if UIDs should be returned
+     * @return array   Search results as list of message IDs or UIDs
+     * @access public
+     */
+    function search_once($mbox_name='', $str=NULL, $ret_uid=false)
+    {
+        if (!$str)
+            return false;
+    
+        $mailbox = $mbox_name ? $this->mod_mailbox($mbox_name) : $this->mailbox;
+
+        return $this->conn->search($mailbox, $str, $ret_uid);
+    }
+
   
     /**
      * Sort thread

Modified: trunk/roundcubemail/program/include/rcube_imap_generic.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_imap_generic.php	2010-03-31 06:25:23 UTC (rev 3445)
+++ trunk/roundcubemail/program/include/rcube_imap_generic.php	2010-03-31 07:14:32 UTC (rev 3446)
@@ -366,7 +366,7 @@
         }
     
         // generate hash
-        $hash  = md5($this->xor($pass,$opad) . pack("H*", md5($this->xor($pass, $ipad) . base64_decode($encChallenge))));
+        $hash  = md5($this->_xor($pass,$opad) . pack("H*", md5($this->_xor($pass, $ipad) . base64_decode($encChallenge))));
     
         // generate reply
         $reply = base64_encode($user . ' ' . $hash);
@@ -1553,18 +1553,19 @@
 	    return false;	
     }
 
-    function search($folder, $criteria)
+    function search($folder, $criteria, $return_uid=false)
     {
 	    if (!$this->select($folder)) {
     		return false;
 	    }
 
     	$data = '';
-	    $query = "srch1 SEARCH " . chop($criteria);
+	    $query = 'srch1 ' . ($return_uid ? 'UID ' : '') . 'SEARCH ' . chop($criteria);
 
 	    if (!$this->putLineC($query)) {
 		    return false;
 	    }
+
     	do {
 	    	$line = trim($this->readLine());
 		    if ($this->startsWith($line, '* SEARCH')) {
@@ -2150,7 +2151,7 @@
 	    return $result;
     }
 
-    private function xor($string, $string2)
+    private function _xor($string, $string2)
     {
 	    $result = '';
 	    $size = strlen($string);

Modified: trunk/roundcubemail/program/steps/mail/sendmail.inc
===================================================================
--- trunk/roundcubemail/program/steps/mail/sendmail.inc	2010-03-31 06:25:23 UTC (rev 3445)
+++ trunk/roundcubemail/program/steps/mail/sendmail.inc	2010-03-31 07:14:32 UTC (rev 3446)
@@ -617,10 +617,10 @@
   if ($olddraftmessageid)
     {
     // delete previous saved draft
-    $a_deleteid = $IMAP->search($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$olddraftmessageid);
+    $a_deleteid = $IMAP->search_once($CONFIG['drafts_mbox'],
+        'HEADER Message-ID '.$olddraftmessageid, true);
+    $deleted = $IMAP->delete_message($a_deleteid, $CONFIG['drafts_mbox']);
 
-    $deleted = $IMAP->delete_message($IMAP->get_uid($a_deleteid[0], $CONFIG['drafts_mbox']), $CONFIG['drafts_mbox']);
-
     // raise error if deletion of old draft failed
     if (!$deleted)
       raise_error(array('code' => 800, 'type' => 'imap',
@@ -639,8 +639,8 @@
   $msgid = strtr($message_id, array('>' => '', '<' => ''));
   
   // remember new draft-uid
-  $draftids = $IMAP->search($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid);
-  $_SESSION['compose']['param']['_draft_uid'] = $IMAP->get_uid($draftids[0], $CONFIG['drafts_mbox']);
+  $draftuids = $IMAP->search_once($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid, true);
+  $_SESSION['compose']['param']['_draft_uid'] = $draftuids[0];
 
   // display success
   $OUTPUT->show_message('messagesaved', 'confirmation');

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list