From bec67c29b42474d41d6324a14ee4f1cd098e1e47 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 17 Oct 2018 13:43:08 +0200 Subject: [PATCH] Display storage errors on refresh/check-recent action (#6474) --- program/include/rcmail.php | 16 ++++++++++++++++ program/steps/mail/check_recent.inc | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/program/include/rcmail.php b/program/include/rcmail.php index f823fab51..43fb4a85b 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -1930,6 +1930,22 @@ class rcmail extends rcube } } + /** + * Displays an error message on storage fatal errors + */ + public function storage_fatal_error() + { + $err_code = $this->storage->get_error_code(); + switch ($err_code) { + // Not all are really fatal, but these should catch + // connection/authentication errors the best we can + case rcube_imap_generic::ERROR_NO: + case rcube_imap_generic::ERROR_BAD: + case rcube_imap_generic::ERROR_BYE: + $this->display_server_error(); + } + } + /** * Output HTML editor scripts * diff --git a/program/steps/mail/check_recent.inc b/program/steps/mail/check_recent.inc index ac0f360eb..dd6e488a4 100644 --- a/program/steps/mail/check_recent.inc +++ b/program/steps/mail/check_recent.inc @@ -54,6 +54,8 @@ else { $plugin = $RCMAIL->plugins->exec_hook('check_recent', array('folders' => $a_mailboxes, 'all' => $check_all)); $a_mailboxes = $plugin['folders']; +$RCMAIL->storage_fatal_error(); + // check recent/unseen counts foreach ($a_mailboxes as $mbox_name) { $is_current = $mbox_name == $current || ($search_request && is_object($_SESSION['search'][1]) && in_array($mbox_name, (array)$_SESSION['search'][1]->get_parameters('MAILBOX'))); @@ -65,6 +67,10 @@ foreach ($a_mailboxes as $mbox_name) { // Get mailbox status $status = $RCMAIL->storage->folder_status($mbox_name, $diff); + if ($is_current) { + $RCMAIL->storage_fatal_error(); + } + if ($status & 1) { // trigger plugin hook $RCMAIL->plugins->exec_hook('new_messages',