From adc08946ef32a1f478973434f912fc4d8d0dfc2c Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 12 Jan 2020 10:29:53 +0100 Subject: [PATCH] Fix unexpected error message when mail refresh involves folder auto-unsubscribe (#6923) --- CHANGELOG | 1 + program/lib/Roundcube/rcube_imap.php | 30 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index bc8075b22..c280cc90d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ CHANGELOG Roundcube Webmail - Elastic: Fix bug where it was possible to switch editor mode when 'htmleditor' was in 'dont_override' (#7143) - Fix regression where "Open in new window" action didn't work (#7155) - Fix PHP Warning: array_filter() expects parameter 1 to be array, null given in subscriptions_option plugin (#7165) +- Fix unexpected error message when mail refresh involves folder auto-unsubscribe (#6923) RELEASE 1.4.2 ------------- diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php index 77baf95b6..6e7822d3b 100644 --- a/program/lib/Roundcube/rcube_imap.php +++ b/program/lib/Roundcube/rcube_imap.php @@ -2946,6 +2946,9 @@ class rcube_imap extends rcube_storage // Add/Remove folders according to some configuration options $this->list_folders_filter($result, $root . $name, ($list_extended ? 'ext-' : '') . 'subscribed'); + // Save the last command state, so we can ignore errors on any following UNSEBSCRIBE calls + $state = $this->save_conn_state(); + if ($list_extended) { // unsubscribe non-existent folders, remove from the list if ($name == '*' && !empty($this->conn->data['LIST'])) { @@ -2977,6 +2980,8 @@ class rcube_imap extends rcube_storage } } + $this->restore_conn_state($state); + return $result; } @@ -4545,6 +4550,31 @@ class rcube_imap extends rcube_storage return $date->format('d-M-Y H:i:s O'); } + /** + * Remember state of the IMAP connection (last IMAP command). + * Use e.g. if you want to execute more commands and ignore results of these. + * + * @return array Connection state + */ + protected function save_conn_state() + { + return array( + $this->conn->error, + $this->conn->errornum, + $this->conn->resultcode, + ); + } + + /** + * Restore saved connection state. + * + * @param array $state Connection result + */ + protected function restore_conn_state($state) + { + list($this->conn->error, $this->conn->errornum, $this->conn->resultcode) = $state; + } + /** * This is our own debug handler for the IMAP connection */