From 19e481fcbfdc096a6ca7b4d253d005e6c635083b Mon Sep 17 00:00:00 2001 From: Markus Schlichting Date: Wed, 6 May 2020 18:06:52 +0200 Subject: [PATCH 1/2] add debug output and missing exception handlers to fix #459 Signed-off-by: Markus Schlichting --- lib/MailQueueHandler.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/MailQueueHandler.php b/lib/MailQueueHandler.php index 5e64a5b79..0fd22aee9 100644 --- a/lib/MailQueueHandler.php +++ b/lib/MailQueueHandler.php @@ -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); @@ -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); @@ -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; } @@ -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); } } From a9dd2c2ed56fb98ef11d9761da176dc2b11edd48 Mon Sep 17 00:00:00 2001 From: Markus Schlichting Date: Fri, 26 Jun 2020 15:26:17 +0200 Subject: [PATCH 2/2] Apply suggestions from code review change the glue for implode from | to , Co-authored-by: kesselb --- lib/MailQueueHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/MailQueueHandler.php b/lib/MailQueueHandler.php index 0fd22aee9..3990dde40 100644 --- a/lib/MailQueueHandler.php +++ b/lib/MailQueueHandler.php @@ -132,7 +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)); + $this->logger->debug('Sending notification emails to users: '. implode(',', $affectedUsers)); $userLanguages = $this->config->getUserValueForUsers('core', 'lang', $affectedUsers); $userTimezones = $this->config->getUserValueForUsers('core', 'timezone', $affectedUsers); @@ -178,7 +178,7 @@ public function sendEmails($limit, $sendTime, $forceSending = false, $restrictEm } $this->activityManager->setRequirePNG(false); - $this->logger->debug('eMail notifications sent. Will delete: ' . implode("|",$deleteItemsForUsers)); + $this->logger->debug('Email notifications sent. Will delete: ' . implode(', ', $deleteItemsForUsers)); // Delete all entries we dealt with $this->deleteSentItems($deleteItemsForUsers, $sendTime);