Skip to content

Commit

Permalink
add debug output and missing exception handlers to fix #459
Browse files Browse the repository at this point in the history
  • Loading branch information
madmas committed May 6, 2020
1 parent e95030e commit e85a42f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/MailQueueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public function sendEmails($limit, $sendTime, $forceSending = false, $restrictEm
// No users found to notify, mission abort
return 0;
}
$this->logger->debug('Sending notification emails to users: '. implode("|",$affectedUsers));

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

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

Expand Down Expand Up @@ -405,6 +407,12 @@ protected function sendEmailToUser($userName, $email, $lang, $timezone, $maxTime
try {
$this->mailer->send($message);
} catch (\Exception $e) {
$this->logger->logException($e, [
'message' => 'Failed sending email to user "{user}"',
'user' => $user,
'app' => 'activity',
]);
$this->activityManager->setCurrentUserId(null);
return false;
}

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

0 comments on commit e85a42f

Please sign in to comment.