Skip to content

Commit

Permalink
pkp#10385 Correct fatal error with notification disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Jan 13, 2025
1 parent 2301330 commit c5ebc05
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function sendMessage(int $userId, Submission $submission, Request $reques

// Create a head note
$headNote = Note::create([
'userId' => $request->getUser()->getId(),
'userId' => $request->getUser()->getId(),
'assocType' => PKPApplication::ASSOC_TYPE_QUERY,
'assocId' => $query->id,
'title' => Mail::compileParams(
Expand All @@ -236,19 +236,22 @@ public function sendMessage(int $userId, Submission $submission, Request $reques
Notification::NOTIFICATION_LEVEL_TASK
);

$mailable->allowUnsubscribe($notification);
$logRepository = null;
try {
Mail::send($mailable);
$logRepository = Repo::emailLogEntry();
} catch (TransportException $e) {
$notificationMgr = new NotificationManager();
$notificationMgr->createTrivialNotification(
$request->getUser()->getId(),
Notification::NOTIFICATION_TYPE_ERROR,
['contents' => __('email.compose.error')]
);
error_log($e->getMessage());
if ($notification) {
// Only send the email if notifications have not been disabled
$mailable->allowUnsubscribe($notification);
try {
Mail::send($mailable);
$logRepository = Repo::emailLogEntry();
} catch (TransportException $e) {
$notificationMgr = new NotificationManager();
$notificationMgr->createTrivialNotification(
$request->getUser()->getId(),
Notification::NOTIFICATION_TYPE_ERROR,
['contents' => __('email.compose.error')]
);
error_log($e->getMessage());
}
}

// remove the INDEX_ and LAYOUT_ tasks if a user has sent the appropriate _COMPLETE email
Expand Down

0 comments on commit c5ebc05

Please sign in to comment.