Mercurial > hg > rc2
comparison program/lib/Roundcube/rcube_imap.php @ 16:1866b439e6d3
Slowly cleaning up more php8 Warnings/deprecations
| author | Charlie Root |
|---|---|
| date | Mon, 06 Oct 2025 10:34:51 -0400 |
| parents | 85a746e95663 |
| children | dd5ed6ef69c9 |
comparison
equal
deleted
inserted
replaced
| 15:85a746e95663 | 16:1866b439e6d3 |
|---|---|
| 661 | 661 |
| 662 // EXISTS is a special alias for ALL, it allows to get the number | 662 // EXISTS is a special alias for ALL, it allows to get the number |
| 663 // of all messages in a folder also when search is active and with | 663 // of all messages in a folder also when search is active and with |
| 664 // any skip_deleted setting | 664 // any skip_deleted setting |
| 665 | 665 |
| 666 $a_folder_cache = $this->get_cache('messagecount'); | 666 if ($this->caching) { |
| 667 | 667 $a_folder_cache = $this->get_cache('messagecount'); |
| 668 // return cached value | 668 |
| 669 if (!$force && is_array($a_folder_cache[$folder]) && isset($a_folder_cache[$folder][$mode])) { | 669 // return cached value |
| 670 if (!$force && is_array($a_folder_cache[$folder]) && isset($a_folder_cache[$folder][$mode])) { | |
| 670 return $a_folder_cache[$folder][$mode]; | 671 return $a_folder_cache[$folder][$mode]; |
| 671 } | 672 } |
| 672 | 673 |
| 673 if (!is_array($a_folder_cache[$folder])) { | 674 if (!is_array($a_folder_cache[$folder])) { |
| 674 $a_folder_cache[$folder] = array(); | 675 $a_folder_cache[$folder] = array(); |
| 675 } | 676 } |
| 676 | 677 } |
| 677 if ($mode == 'THREADS') { | 678 if ($mode == 'THREADS') { |
| 678 $res = $this->threads($folder); | 679 $res = $this->threads($folder); |
| 679 $count = $res->count(); | 680 $count = $res->count(); |
| 680 | 681 |
| 681 if ($status) { | 682 if ($status) { |
| 682 $msg_count = $res->count_messages(); | 683 $msg_count = $res->count_messages(); |
| 683 $this->set_folder_stats($folder, 'cnt', $msg_count); | 684 $this->set_folder_stats($folder, 'cnt', $msg_count); |
| 684 $this->set_folder_stats($folder, 'maxuid', $msg_count ? $this->id2uid($msg_count, $folder) : 0); | 685 $this->set_folder_stats($folder, 'maxuid', $msg_count ? $this->id2uid($msg_count, $folder) : 0); |
| 685 } | 686 } |
| 686 } | 687 } |
| 687 // Need connection here | 688 // Need connection here |
| 688 else if (!$this->check_connection()) { | 689 else if (!$this->check_connection()) { |
| 689 return 0; | 690 return 0; |
| 690 } | 691 } |
| 691 // RECENT count is fetched a bit different | 692 // RECENT count is fetched a bit different |
| 692 else if ($mode == 'RECENT') { | 693 else if ($mode == 'RECENT') { |
| 693 $count = $this->conn->countRecent($folder); | 694 $count = $this->conn->countRecent($folder); |
| 694 } | 695 } |
| 695 // use SEARCH for message counting | 696 // use SEARCH for message counting |
| 696 else if ($mode != 'EXISTS' && !empty($this->options['skip_deleted'])) { | 697 else if ($mode != 'EXISTS' && !empty($this->options['skip_deleted'])) { |
| 697 $search_str = "ALL UNDELETED"; | 698 $search_str = "ALL UNDELETED"; |
| 698 $keys = array('COUNT'); | 699 $keys = array('COUNT'); |
| 699 | 700 |
| 700 if ($mode == 'UNSEEN') { | 701 if ($mode == 'UNSEEN') { |
| 701 $search_str .= " UNSEEN"; | 702 $search_str .= " UNSEEN"; |
| 702 } | 703 } |
| 703 else { | 704 else { |
| 704 if ($this->messages_caching) { | 705 if ($this->messages_caching) { |
| 705 $keys[] = 'ALL'; | 706 $keys[] = 'ALL'; |
| 706 } | 707 } |
| 707 if ($status) { | 708 if ($status) { |
| 708 $keys[] = 'MAX'; | 709 $keys[] = 'MAX'; |
| 709 } | 710 } |
| 710 } | 711 } |
| 711 | 712 |
| 712 // @TODO: if $mode == 'ALL' we could try to use cache index here | 713 // @TODO: if $mode == 'ALL' we could try to use cache index here |
| 713 | 714 |
| 714 // get message count using (E)SEARCH | 715 // get message count using (E)SEARCH |
| 715 // not very performant but more precise (using UNDELETED) | 716 // not very performant but more precise (using UNDELETED) |
| 716 $index = $this->conn->search($folder, $search_str, true, $keys); | 717 $index = $this->conn->search($folder, $search_str, true, $keys); |
| 717 $count = $index->count(); | 718 $count = $index->count(); |
| 718 | 719 |
| 719 if ($mode == 'ALL') { | 720 if ($mode == 'ALL') { |
| 720 // Cache index data, will be used in index_direct() | 721 // Cache index data, will be used in index_direct() |
| 721 $this->icache['undeleted_idx'] = $index; | 722 $this->icache['undeleted_idx'] = $index; |
| 722 | 723 |
| 723 if ($status) { | 724 if ($status) { |
| 724 $this->set_folder_stats($folder, 'cnt', $count); | 725 $this->set_folder_stats($folder, 'cnt', $count); |
| 725 $this->set_folder_stats($folder, 'maxuid', $index->max()); | 726 $this->set_folder_stats($folder, 'maxuid', $index->max()); |
| 726 } | 727 } |
| 727 } | 728 } |
| 728 } | 729 } |
| 729 else { | 730 else { |
| 730 if ($mode == 'UNSEEN') { | 731 if ($mode == 'UNSEEN') { |
| 731 $count = $this->conn->countUnseen($folder); | 732 $count = $this->conn->countUnseen($folder); |
| 732 } | 733 } |
| 733 else { | 734 else { |
| 734 $count = $this->conn->countMessages($folder); | 735 $count = $this->conn->countMessages($folder); |
| 735 if ($status && $mode == 'ALL') { | 736 if ($status && $mode == 'ALL') { |
| 736 $this->set_folder_stats($folder, 'cnt', $count); | 737 $this->set_folder_stats($folder, 'cnt', $count); |
| 737 $this->set_folder_stats($folder, 'maxuid', $count ? $this->id2uid($count, $folder) : 0); | 738 $this->set_folder_stats($folder, 'maxuid', $count ? $this->id2uid($count, $folder) : 0); |
| 738 } | 739 } |
| 739 } | 740 } |
| 740 } | 741 } |
| 741 | 742 |
| 742 $a_folder_cache[$folder][$mode] = (int)$count; | 743 if ($this->caching) { |
| 743 | 744 $a_folder_cache[$folder][$mode] = (int)$count; |
| 744 // write back to cache | 745 |
| 745 $this->update_cache('messagecount', $a_folder_cache); | 746 // write back to cache |
| 747 $this->update_cache('messagecount', $a_folder_cache); | |
| 748 } | |
| 746 | 749 |
| 747 return (int)$count; | 750 return (int)$count; |
| 748 } | 751 } |
| 749 | 752 |
| 750 /** | 753 /** |
| 4087 * @param mixed $data Data | 4090 * @param mixed $data Data |
| 4088 */ | 4091 */ |
| 4089 public function update_cache($key, $data) | 4092 public function update_cache($key, $data) |
| 4090 { | 4093 { |
| 4091 if ($cache = $this->get_cache_engine()) { | 4094 if ($cache = $this->get_cache_engine()) { |
| 4095 | |
| 4092 $cache->set($key, $data); | 4096 $cache->set($key, $data); |
| 4097 rcube::write_log('mail',"cache " . !(!$cache) . " for " . $key); | |
| 4093 } | 4098 } |
| 4094 } | 4099 } |
| 4095 | 4100 |
| 4096 /** | 4101 /** |
| 4097 * Clears the cache. | 4102 * Clears the cache. |
| 4345 /** | 4350 /** |
| 4346 * Increde/decrese messagecount for a specific folder | 4351 * Increde/decrese messagecount for a specific folder |
| 4347 */ | 4352 */ |
| 4348 protected function set_messagecount($folder, $mode, $increment) | 4353 protected function set_messagecount($folder, $mode, $increment) |
| 4349 { | 4354 { |
| 4350 if (!is_numeric($increment)) { | 4355 if (!is_numeric($increment) || !$this->caching) { |
| 4351 return false; | 4356 return false; |
| 4352 } | 4357 } |
| 4353 | 4358 |
| 4354 $mode = strtoupper($mode); | 4359 $mode = strtoupper($mode); |
| 4355 $a_folder_cache = $this->get_cache('messagecount'); | 4360 $a_folder_cache = $this->get_cache('messagecount'); |
