Fix wrong messages order after returning to a multi-folder search result (#6836)

pull/6852/head
Aleksander Machniak 5 years ago
parent 0e4bf6fda8
commit 786bde62f2

@ -71,6 +71,7 @@ CHANGELOG Roundcube Webmail
- Fix bug in converting multi-page Tiff images to Jpeg (#6824)
- Fix bug where handling multiple messages from multi-folder search result could not work (#6845)
- Fix bug where unread count wasn't updated after moving multi-folder result (#6846)
- Fix wrong messages order after returning to a multi-folder search result (#6836)
RELEASE 1.4-rc1
---------------

@ -1103,8 +1103,10 @@ class rcube_imap extends rcube_storage
}
// slice resultset first...
$index = array_slice($search_set->get(), $from, $slice_length);
$fetch = array();
foreach (array_slice($search_set->get(), $from, $slice_length) as $msg_id) {
foreach ($index as $msg_id) {
list($uid, $folder) = explode('-', $msg_id, 2);
$fetch[$folder][] = $uid;
}
@ -1114,6 +1116,11 @@ class rcube_imap extends rcube_storage
foreach ($fetch as $folder => $a_index) {
$a_msg_headers = array_merge($a_msg_headers, array_values($this->fetch_headers($folder, $a_index)));
}
// Re-sort the result according to the original search set order
usort($a_msg_headers, function($a, $b) use ($index) {
return array_search($a->uid . '-' . $a->folder, $index) - array_search($b->uid . '-' . $b->folder, $index);
});
}
if ($slice) {

Loading…
Cancel
Save