Changeset 5029 in subversion
- Timestamp:
- Aug 8, 2011 8:14:49 AM (23 months ago)
- Location:
- branches/devel-mcache/roundcubemail/program/include
- Files:
-
- 3 edited
-
rcube_imap.php (modified) (5 diffs)
-
rcube_imap_cache.php (modified) (7 diffs)
-
rcube_imap_generic.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/devel-mcache/roundcubemail/program/include/rcube_imap.php
r5028 r5029 892 892 else if ($this->get_capability('SORT') && 893 893 // Courier-IMAP provides SORT capability but allows to disable it by admin (#1486959) 894 ($msg_index = $this->conn->sort($mailbox, $this->sort_field, $this->skip_deleted ? 'UNDELETED' : '')) !== false 894 ($msg_index = $this->conn->sort($mailbox, $this->sort_field, 895 $this->skip_deleted ? 'UNDELETED' : '', true)) !== false 895 896 ) { 896 897 if (!empty($msg_index)) { 897 898 list($begin, $end) = $this->_get_message_range(count($msg_index), $page); 898 899 $msg_index = array_slice($msg_index, $begin, $end-$begin); 900 $is_uid = true; 899 901 900 902 if ($slice) … … 902 904 903 905 // fetch reqested headers from server 904 $a_msg_headers = $this->fetch_headers($mailbox, $msg_index );906 $a_msg_headers = $this->fetch_headers($mailbox, $msg_index, true); 905 907 } 906 908 } 907 909 // fetch specified header for all messages and sort 908 else if ($a_index = $this->conn->fetchHeaderIndex($mailbox, "1:*", $this->sort_field, $this->skip_deleted)) { 909 asort($a_index); // ASC 910 $msg_index = array_keys($a_index); 910 else if ($msg_index = $this->conn->fetchHeaderIndex($mailbox, "1:*", 911 $this->sort_field, $this->skip_deleted, true) 912 ) { 913 asort($msg_index); // ASC 914 $msg_index = array_keys($msg_index); 911 915 list($begin, $end) = $this->_get_message_range(count($msg_index), $page); 912 916 $msg_index = array_slice($msg_index, $begin, $end-$begin); 917 $is_uid = true; 913 918 914 919 if ($slice) … … 916 921 917 922 // fetch reqested headers from server 918 $a_msg_headers = $this->fetch_headers($mailbox, $msg_index );923 $a_msg_headers = $this->fetch_headers($mailbox, $msg_index, true); 919 924 } 920 925 … … 1662 1667 1663 1668 // Error, try with US-ASCII (RFC5256: SORT/THREAD must support US-ASCII and UTF-8, 1664 // but I've seen that Courier doesn't support UTF-8)1669 // but I've seen Courier with disabled UTF-8 support) 1665 1670 if ($a_messages === false && $charset && $charset != 'US-ASCII') 1666 1671 $a_messages = $this->conn->sort($mailbox, $sort_field, … … 4500 4505 function sort_headers(&$headers) 4501 4506 { 4502 if (!empty($ uids))4507 if (!empty($this->uids)) 4503 4508 uksort($headers, array($this, "compare_uids")); 4504 4509 else -
branches/devel-mcache/roundcubemail/program/include/rcube_imap_cache.php
r5028 r5029 98 98 // Seek in internal cache 99 99 if (array_key_exists('index', $this->icache[$mailbox]) 100 && ($ this->icache[$mailbox]['index']['sort_field'] == $sort_field)100 && ($sort_field == 'ANY' || $this->icache[$mailbox]['index']['sort_field'] == $sort_field) 101 101 ) { 102 102 if ($this->icache[$mailbox]['index']['sort_order'] == $sort_order) … … 122 122 if (!empty($index)) { 123 123 $exists = true; 124 if ($sort_field == 'ANY') { 125 $sort_field = $index['sort_field']; 126 } 124 127 125 128 // Check UIDVALIDITY … … 195 198 } 196 199 } 197 198 $this->icache[$mailbox]['index'] = array( 199 'result' => $data, 200 'sort_field' => $sort_field, 201 'sort_order' => $sort_order, 202 ); 203 204 if ($data !== null) { 205 return $data; 200 else if ($sort_field == 'ANY') { 201 $sort_field = ''; 206 202 } 207 203 208 204 // Index not found or not valid, get index from IMAP server 209 $data = array(); 210 if ($mbox_data['EXISTS']) { 211 // fetch sorted sequence numbers 212 $data_seq = $this->imap->message_index_direct($mailbox, $sort_field, $sort_order); 213 // fetch UIDs 214 if (!empty($data_seq)) { 215 $data_uid = $this->imap->conn->fetchUIDs($mailbox, $data_seq); 216 // build index 217 if (!empty($data_uid)) { 218 foreach ($data_seq as $seq) 219 if ($uid = $data_uid[$seq]) 220 $data[$seq] = $uid; 221 } 222 } 223 } 224 225 if (is_array($data)) { 205 if ($data === null) { 206 $data = array(); 207 if ($mbox_data['EXISTS']) { 208 // fetch sorted sequence numbers 209 $data_seq = $this->imap->message_index_direct($mailbox, $sort_field, $sort_order); 210 // fetch UIDs 211 if (!empty($data_seq)) { 212 // Seek in internal cache 213 if (array_key_exists('index', $this->icache[$mailbox])) 214 $data_uid = $this->icache[$mailbox]['index']['result']; 215 else 216 $data_uid = $this->imap->conn->fetchUIDs($mailbox, $data_seq); 217 218 // build index 219 if (!empty($data_uid)) { 220 foreach ($data_seq as $seq) 221 if ($uid = $data_uid[$seq]) 222 $data[$seq] = $uid; 223 } 224 } 225 } 226 226 227 $in_data = implode(':', array( 227 228 implode(',', array_keys($data)), 228 229 implode(',', array_values($data)), 229 230 $sort_order, 230 (int) $this->skip_deleted,231 (int) $mbox_data['UIDVALIDITY'],231 (int) $this->skip_deleted, 232 (int) $mbox_data['UIDVALIDITY'], 232 233 )); 233 234 … … 246 247 ." VALUES (?, ?, ?, 0, ?, ".$this->db->now().")", 247 248 $this->userid, $mailbox, (string)$sort_field, $in_data); 248 249 } 250 251 return $this->icache[$mailbox]['index']['result'] = (array)$data; 249 } 250 251 $this->icache[$mailbox]['index'] = array( 252 'result' => $data, 253 'sort_field' => $sort_field, 254 'sort_order' => $sort_order, 255 ); 256 257 return $this->icache[$mailbox]['index']['result']; 252 258 } 253 259 … … 431 437 function id2uid($mailbox, $id) 432 438 { 433 $index = $this->get_index($mailbox );439 $index = $this->get_index($mailbox, 'ANY'); 434 440 435 441 return $index[$id]; … … 445 451 function uid2id($mailbox, $uid) 446 452 { 447 $index = $this->get_index($mailbox );453 $index = $this->get_index($mailbox, 'ANY'); 448 454 449 455 return array_search($uid, $index); … … 456 462 private function get_index_row($mailbox, $sort_field, $threaded = false) 457 463 { 458 // Get index from DB, for query with no sort_field specified 459 // we'll get most recent index data 460 $sql_result = $this->db->query( 461 "SELECT data, sort_field" 462 ." FROM ".get_table_name('cache_index') 463 ." WHERE user_id = ?" 464 ." AND mailbox = ?" 465 ." AND sort_field = ?" 466 ." AND threaded = ?", 467 $this->userid, $mailbox, (string)$sort_field, (int)$threaded); 464 // Get index from DB 465 // There's a special case when we want most recent index 466 if ($sort_field == 'ANY') 467 $sql_result = $this->db->limitquery( 468 "SELECT data, sort_field" 469 ." FROM ".get_table_name('cache_index') 470 ." WHERE user_id = ?" 471 ." AND mailbox = ?" 472 ." AND threaded = ?" 473 ." ORDER BY changed DESC", 474 0, 1, $this->userid, $mailbox, (int)$threaded); 475 else 476 $sql_result = $this->db->query( 477 "SELECT data, sort_field" 478 ." FROM ".get_table_name('cache_index') 479 ." WHERE user_id = ?" 480 ." AND mailbox = ?" 481 ." AND threaded = ?" 482 ." AND sort_field = ?", 483 $this->userid, $mailbox, (int)$threaded, (string)$sort_field); 468 484 469 485 if ($sql_arr = $this->db->fetch_assoc($sql_result)) { -
branches/devel-mcache/roundcubemail/program/include/rcube_imap_generic.php
r5028 r5029 62 62 public $forwarded = false; 63 63 public $flagged = false; 64 public $has_children = false;65 public $depth = 0;66 public $unread_children = 0;67 64 public $others = array(); 68 65 }
Note: See TracChangeset
for help on using the changeset viewer.
