diff --git a/CHANGELOG b/CHANGELOG index 416ed4e97ac..7eb1f28873b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ CHANGELOG Roundcube Webmail - Fix error causing empty INBOX listing in Firefox when using an URL with user:password specified (#5400) - Fix PHP warning when handling shared namespace with empty prefix (#5420) - Fix so folders list is scrolled to the selected folder on page load (#5424) +- Fix so when moving to Trash we make sure the folder exists (#5192) RELEASE 1.2.1 ------------- diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php index f8c8c3dd3b1..8a8af455244 100644 --- a/program/lib/Roundcube/rcube_imap.php +++ b/program/lib/Roundcube/rcube_imap.php @@ -2592,6 +2592,14 @@ public function move_message($uids, $to_mbox, $from_mbox='') // move messages $moved = $this->conn->move($uids, $from_mbox, $to_mbox); + // when moving to Trash we make sure the folder exists + // as it's uncommon scenario we do this when MOVE fails, not before + if (!$moved && $to_trash && $this->get_response_code() == rcube_storage::TRYCREATE) { + if ($this->create_folder($to_mbox, true, 'trash')) { + $moved = $this->conn->move($uids, $from_mbox, $to_mbox); + } + } + if ($moved) { $this->clear_messagecount($from_mbox); $this->clear_messagecount($to_mbox);