From e660f157c017e7e49ba26b3dac7f52161dff803c Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sat, 28 May 2016 09:31:59 +0200 Subject: [PATCH] Fix multi-folder search issues in "this and subfolders" scope (#5282, #5259) - Fix bug where multi-folder search could choose a wrong folder - Fix bug where multi-folder search didn't work for unsubscribed INBOX --- CHANGELOG | 2 ++ program/lib/Roundcube/rcube_imap.php | 8 ++++++-- program/steps/mail/search.inc | 7 +++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 690260bb3..cb2a85f68 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,8 @@ CHANGELOG Roundcube Webmail - Fix PHP warning when password_hosts is set, but is not an array (#5260) - Fix redundant keep-alive requests when session_lifetime is greater than ~20000 (#5273) - Fix so subfolders of INBOX can be set as Archive (#5274) +- Fix bug where multi-folder search could choose a wrong folder in "this and subfolders" scope (#5282) +- Fix bug where multi-folder search didn't work for unsubscribed INBOX (#5259) RELEASE 1.2.0 ------------- diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php index 52ca22ccf..4a9fdb741 100644 --- a/program/lib/Roundcube/rcube_imap.php +++ b/program/lib/Roundcube/rcube_imap.php @@ -2811,7 +2811,9 @@ class rcube_imap extends rcube_storage } // INBOX should always be available - if (!strlen($root) && (!$filter || $filter == 'mail') && !in_array('INBOX', $a_mboxes)) { + if (in_array_nocase($root . $name, array('*', '%', 'INBOX', 'INBOX*')) + && (!$filter || $filter == 'mail') && !in_array('INBOX', $a_mboxes) + ) { array_unshift($a_mboxes, 'INBOX'); } @@ -2942,7 +2944,9 @@ class rcube_imap extends rcube_storage } // INBOX should always be available - if (!strlen($root) && (!$filter || $filter == 'mail') && !in_array('INBOX', $a_mboxes)) { + if (in_array_nocase($root . $name, array('*', '%', 'INBOX', 'INBOX*')) + && (!$filter || $filter == 'mail') && !in_array('INBOX', $a_mboxes) + ) { array_unshift($a_mboxes, 'INBOX'); } diff --git a/program/steps/mail/search.inc b/program/steps/mail/search.inc index ee6ba8816..64763d928 100644 --- a/program/steps/mail/search.inc +++ b/program/steps/mail/search.inc @@ -129,10 +129,9 @@ if ($search_str) { natcasesort($mboxes); // we want natural alphabetic sorting of folders in the result set } else if ($scope == 'sub') { - $mboxes = $RCMAIL->storage->list_folders_subscribed($mbox, '*', 'mail'); - if ($mbox != 'INBOX' && $mboxes[0] == 'INBOX') { - array_shift($mboxes); - } + $delim = $RCMAIL->storage->get_hierarchy_delimiter(); + $mboxes = $RCMAIL->storage->list_folders_subscribed($mbox . $delim, '*', 'mail'); + array_unshift($mboxes, $mbox); } $result = $RCMAIL->storage->search($mboxes, $search_str, $imap_charset, $sort_column);