Skip to content

Commit e85a42f

Browse files
committed
add debug output and missing exception handlers to fix #459
1 parent e95030e commit e85a42f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/MailQueueHandler.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public function sendEmails($limit, $sendTime, $forceSending = false, $restrictEm
132132
// No users found to notify, mission abort
133133
return 0;
134134
}
135+
$this->logger->debug('Sending notification emails to users: '. implode("|",$affectedUsers));
135136

136137
$userLanguages = $this->config->getUserValueForUsers('core', 'lang', $affectedUsers);
137138
$userTimezones = $this->config->getUserValueForUsers('core', 'timezone', $affectedUsers);
@@ -177,6 +178,7 @@ public function sendEmails($limit, $sendTime, $forceSending = false, $restrictEm
177178
}
178179
$this->activityManager->setRequirePNG(false);
179180

181+
$this->logger->debug('eMail notifications sent. Will delete: ' . implode("|",$deleteItemsForUsers));
180182
// Delete all entries we dealt with
181183
$this->deleteSentItems($deleteItemsForUsers, $sendTime);
182184

@@ -405,6 +407,12 @@ protected function sendEmailToUser($userName, $email, $lang, $timezone, $maxTime
405407
try {
406408
$this->mailer->send($message);
407409
} catch (\Exception $e) {
410+
$this->logger->logException($e, [
411+
'message' => 'Failed sending email to user "{user}"',
412+
'user' => $user,
413+
'app' => 'activity',
414+
]);
415+
$this->activityManager->setCurrentUserId(null);
408416
return false;
409417
}
410418

@@ -498,6 +506,8 @@ protected function deleteSentItems(array $affectedUsers, $maxTime) {
498506
$query->delete('activity_mq')
499507
->where($query->expr()->lte('amq_timestamp', $query->createNamedParameter($maxTime, IQueryBuilder::PARAM_INT)))
500508
->andWhere($query->expr()->in('amq_affecteduser', $query->createNamedParameter($affectedUsers, IQueryBuilder::PARAM_STR_ARRAY), IQueryBuilder::PARAM_STR));
501-
$query->execute();
509+
$this->logger->debug('Delete SQL: ' . $query->getSQL());
510+
$result = $query->execute();
511+
$this->logger->debug('Delete Statement returned: ' . $result);
502512
}
503513
}

0 commit comments

Comments
 (0)