From dc70d06144e148e462ffa2115555ed055c98c67e Mon Sep 17 00:00:00 2001 From: Glandos Date: Wed, 26 Mar 2014 15:34:15 +0100 Subject: [PATCH] Small performance improvement on imap_open MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the OP_HALFOPEN flag to reduce server load. We don't need to open a mailbox, so just don't try I've also make the check clearer for the opened connection (I know, 2 PR in one, it's bad…) --- lib/imap.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/imap.php b/lib/imap.php index 19e792d..c39593c 100644 --- a/lib/imap.php +++ b/lib/imap.php @@ -42,10 +42,10 @@ class OC_User_IMAP extends \OCA\user_external\Base { OCP\Util::writeLog('user_external', 'ERROR: PHP imap extension is not installed', OCP\Util::ERROR); return false; } - $mbox = @imap_open($this->mailbox, $uid, $password); + $mbox = @imap_open($this->mailbox, $uid, $password, OP_HALFOPEN); imap_errors(); imap_alerts(); - if($mbox) { + if($mbox !== FALSE) { imap_close($mbox); $this->storeUser($uid); return $uid;