Changeset 2676 in subversion
- Timestamp:
- Jun 24, 2009 7:49:49 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/include/rcube_imap.php
r2675 r2676 795 795 // add message to cache 796 796 if ($this->caching_enabled && $cache_index[$headers->id] != $headers->uid) 797 $this->add_message_cache($cache_key, $headers->id, $headers); 797 $this->add_message_cache($cache_key, $headers->id, $headers, NULL, 798 !in_array((string)$headers->uid, $cache_index, true)); 798 799 799 800 $a_msg_headers[$headers->uid] = $headers; … … 913 914 if (in_array((string)$uid, $cache_index, TRUE)) 914 915 { 915 unset($cache_index[$id]); 916 unset($cache_index[$id]); 916 917 } 917 918 … … 937 938 if ($headers = iil_C_FetchHeader($this->conn, $mailbox, join(',', $for_update), false, $this->fetch_add_headers)) 938 939 foreach ($headers as $header) 939 $this->add_message_cache($cache_key, $header->id, $header); 940 $this->add_message_cache($cache_key, $header->id, $header, NULL, 941 in_array((string)$header->uid, $for_remove, true)); 940 942 } 941 943 } … … 1086 1088 $this->uid_id_map[$mailbox][$headers->uid] = $headers->id; 1087 1089 1088 $this->add_message_cache($mailbox.'.msg', $headers->id, $headers );1090 $this->add_message_cache($mailbox.'.msg', $headers->id, $headers, NULL, true); 1089 1091 } 1090 1092 … … 1104 1106 { 1105 1107 $cache_key = $this->mailbox.'.msg'; 1106 $headers = &$this->get_cached_message($cache_key, $uid , true);1108 $headers = &$this->get_cached_message($cache_key, $uid); 1107 1109 1108 1110 // return cached message structure … … 2201 2203 * @return int -3 = off, -2 = incomplete, -1 = dirty 2202 2204 */ 2203 function check_cache_status($mailbox, $cache_key)2205 private function check_cache_status($mailbox, $cache_key) 2204 2206 { 2205 2207 if (!$this->caching_enabled) … … 2247 2249 * @access private 2248 2250 */ 2249 function get_message_cache($key, $from, $to, $sort_field, $sort_order)2251 private function get_message_cache($key, $from, $to, $sort_field, $sort_order) 2250 2252 { 2251 2253 $cache_key = "$key:$from:$to:$sort_field:$sort_order"; … … 2286 2288 * @access private 2287 2289 */ 2288 function &get_cached_message($key, $uid, $struct=false)2290 private function &get_cached_message($key, $uid) 2289 2291 { 2290 2292 $internal_key = '__single_msg'; … … 2293 2295 ($struct && empty($this->cache[$internal_key][$uid]->structure)))) 2294 2296 { 2295 $sql_select = "idx, uid, headers" . ($struct ? ", structure" : '');2296 2297 $sql_result = $this->db->query( 2297 "SELECT $sql_select2298 "SELECT idx, headers, structure 2298 2299 FROM ".get_table_name('messages')." 2299 2300 WHERE user_id=? … … 2303 2304 $key, 2304 2305 $uid); 2306 2305 2307 if ($sql_arr = $this->db->fetch_assoc($sql_result)) 2306 2308 { 2309 $this->uid_id_map[preg_replace('/\.msg$/', '', $key)][$uid] = $sql_arr['idx']; 2307 2310 $this->cache[$internal_key][$uid] = $this->db->decode(unserialize($sql_arr['headers'])); 2308 2311 if (is_object($this->cache[$internal_key][$uid]) && !empty($sql_arr['structure'])) … … 2317 2320 * @access private 2318 2321 */ 2319 function get_message_cache_index($key, $force=FALSE, $sort_field='idx', $sort_order='ASC')2322 private function get_message_cache_index($key, $force=FALSE, $sort_field='idx', $sort_order='ASC') 2320 2323 { 2321 2324 static $sa_message_index = array(); … … 2347 2350 * @access private 2348 2351 */ 2349 private function add_message_cache($key, $index, $headers, $struct=null )2352 private function add_message_cache($key, $index, $headers, $struct=null, $force=false) 2350 2353 { 2351 2354 if (empty($key) || !is_object($headers) || empty($headers->uid)) … … 2353 2356 2354 2357 // add to internal (fast) cache 2355 $this->cache['__single_msg'][$headers->uid] = $headers;2358 $this->cache['__single_msg'][$headers->uid] = clone $headers; 2356 2359 $this->cache['__single_msg'][$headers->uid]->structure = $struct; 2357 2360 … … 2361 2364 2362 2365 // check for an existing record (probly headers are cached but structure not) 2363 $sql_result = $this->db->query( 2366 if (!$force) { 2367 $sql_result = $this->db->query( 2364 2368 "SELECT message_id 2365 2369 FROM ".get_table_name('messages')." … … 2371 2375 $key, 2372 2376 $headers->uid); 2377 if ($sql_arr = $this->db->fetch_assoc($sql_result)) 2378 $message_id = $sql_arr['message_id']; 2379 } 2373 2380 2374 2381 // update cache record 2375 if ($ sql_arr = $this->db->fetch_assoc($sql_result))2382 if ($message_id) 2376 2383 { 2377 2384 $this->db->query( … … 2382 2389 serialize($this->db->encode(clone $headers)), 2383 2390 is_object($struct) ? serialize($this->db->encode(clone $struct)) : NULL, 2384 $ sql_arr['message_id']2391 $message_id 2385 2392 ); 2386 2393 } … … 2395 2402 $index, 2396 2403 $headers->uid, 2397 2398 2404 (string)rc_substr($this->db->encode($this->decode_header($headers->subject, TRUE)), 0, 128), 2399 2405 (string)rc_substr($this->db->encode($this->decode_header($headers->from, TRUE)), 0, 128),
Note: See TracChangeset
for help on using the changeset viewer.
