check for errors before printing

Signed-off-by: Anojh Thayaparan <anojh@hotmail.com>
This commit is contained in:
Anojh Thayaparan
2019-01-30 08:10:11 -08:00
parent ba19fc9515
commit 58dd7465b9

View File

@@ -67,14 +67,20 @@ class OC_User_IMAP extends \OCA\user_external\Base {
}
$mbox = @imap_open($this->mailbox, $username, $password, OP_HALFOPEN, 1);
OC::$server->getLogger()->error(
'ERROR: IMAP Error: ' . print_r(imap_errors(), true),
['app' => 'user_external']
);
OC::$server->getLogger()->warning(
'WARNING: IMAP Warning: ' . print_r(imap_alerts(), true),
['app' => 'user_external']
);
$imapErrors = imap_errors();
$imapAlerts = imap_alerts();
if (!empty($imapErrors) {
OC::$server->getLogger()->error(
'ERROR: IMAP Error: ' . print_r($imapErrors, true),
['app' => 'user_external']
);
}
if (!empty($imapAlerts)) {
OC::$server->getLogger()->warning(
'WARNING: IMAP Warning: ' . print_r($imapAlerts, true),
['app' => 'user_external']
);
}
if($mbox !== false) {
imap_close($mbox);
$uid = mb_strtolower($uid);