Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add debug output and missing exception handlers to fix #459 #460

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor

@kesselb kesselb Jun 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log the exception with $this->logger->logException($e); and log a additional warning $this->logger->warning('Failed to send notification email for user {user}', ['user' => $userName]);. You cannot use $user because it's a IUser object. Ah that might work as the normalizer will format it. I would still prefer the $userName ;)

'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);
}
}