summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-09-16 11:29:53 +0000
committeralecpl <alec@alec.pl>2010-09-16 11:29:53 +0000
commit431234538a789ce5f56e33b6e61f6e0e4ae386d1 (patch)
tree8b9ac28788846c115b0c2c11096a2a53a62b8017
parent2280757d240cb365b2f33b6de154b29d6573e566 (diff)
- Fix when IMAP connection fails in 'get' action session shouldn't be destroyed (#1486995)
- Performance: improve mail/get action and skip one IMAP connection
-rw-r--r--CHANGELOG1
-rw-r--r--program/steps/mail/func.inc4
-rw-r--r--program/steps/mail/get.inc24
3 files changed, 27 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index f6a99a2d8..fa79fa948 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -22,6 +22,7 @@ CHANGELOG RoundCube Webmail
- Fix handling of charsets with LATIN-* label
- Fix messages background image handling in some cases (#1486990)
- Fix format=flowed handling (#1486989)
+- Fix when IMAP connection fails in 'get' action session shouldn't be destroyed (#1486995)
RELEASE 0.4
-----------
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 39d77eab1..eb785ca68 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -26,8 +26,8 @@ $SEARCH_MODS_DEFAULT = array('*' => array('subject'=>1, 'from'=>1), $SENT_MBOX =
$EMAIL_ADDRESS_PATTERN = '([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9][a-z0-9\-\.]*\\.[a-z]{2,5})';
-// actions that do not require imap connection
-$NOIMAP_ACTIONS = array('addcontact', 'autocomplete', 'upload', 'display-attachment', 'remove-attachment');
+// actions that do not require imap connection here
+$NOIMAP_ACTIONS = array('addcontact', 'autocomplete', 'upload', 'display-attachment', 'remove-attachment', 'get');
// always instantiate imap object (but not yet connect to server)
$RCMAIL->imap_init();
diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc
index 67c62b284..50731e012 100644
--- a/program/steps/mail/get.inc
+++ b/program/steps/mail/get.inc
@@ -35,6 +35,30 @@ if (!empty($_GET['_preload'])) {
ob_end_clean();
+// Now we need IMAP connection
+if (!$RCMAIL->imap_connect()) {
+ // Get action is often executed simultanously.
+ // Some servers have MAXPERIP or other limits.
+ // To workaround this we'll wait for some time
+ // and try again (once).
+ // Note: When message contains more inline parts and the server limit is low
+ // this stil maybe the issue, while we're using the same sleep interval, but
+ // I didn't found better solution.
+ if (!isset($_GET['_redirected'])) {
+ sleep(2);
+ header('Location: ' . $_SERVER['REQUEST_URI'] . '&_redirected=1');
+ }
+ else {
+ raise_error(array(
+ 'code' => 500, 'type' => 'php',
+ 'file' => __FILE__, 'line' => __LINE__,
+ 'message' => 'Unable to get/display message part. IMAP connection error'),
+ true, true);
+ }
+ // Don't kill session, just quit (#1486995)
+ exit;
+}
+
// similar code as in program/steps/mail/show.inc
if (!empty($_GET['_uid'])) {
$RCMAIL->config->set('prefer_html', true);