From 2c05121fe69f0c362e8b1a1f829e3d5163b671dd Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Tue, 19 May 2026 20:33:35 +0200 Subject: [PATCH] fix(NotificationGenerator): catch InvalidArgumentException from notification setters in prepare() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit INotification setters like setRichSubject() and setParsedSubject() throw \InvalidArgumentException for empty/invalid values, which previously escaped prepare() — triggering the NC39 deprecation. Catch and discard the notification as already-processed since it cannot be rendered. AI-Assisted-By: Claude Sonnet 4.6 Signed-off-by: Anna Larch --- lib/NotificationGenerator.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/NotificationGenerator.php b/lib/NotificationGenerator.php index 99e3e3b70..367cbc16b 100644 --- a/lib/NotificationGenerator.php +++ b/lib/NotificationGenerator.php @@ -118,7 +118,12 @@ public function prepare(INotification $notification, string $languageCode): INot $event = $this->populateEvent($event, $languageCode); $this->activityManager->setCurrentUserId(null); - return $this->getDisplayNotificationForEvent($event, $event->getObjectId()); + try { + return $this->getDisplayNotificationForEvent($event, $event->getObjectId()); + } catch (\InvalidArgumentException $e) { + $this->logger->error('Failed to format activity notification', ['exception' => $e]); + throw new AlreadyProcessedException(); + } } private function getDisplayNotificationForEvent(IEvent $event, int $activityId): INotification {