From 7c61c91195a5351616de6b84cc871775173845d8 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Thu, 8 Feb 2024 14:25:06 +0100 Subject: [PATCH] Fix issue when sending notifications about moderation comments If the e-mail notifications were created as a daily summary, the use of `ViewableModerationQueue::getViewableModerationQueue()` was not reliable, as the ID of the activate user was used there. --- ...entResponseUserNotificationEvent.class.php | 5 +++-- ...ueueCommentUserNotificationEvent.class.php | 22 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php index b761430789..f80e501147 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php @@ -2,6 +2,7 @@ namespace wcf\system\user\notification\event; +use wcf\data\moderation\queue\ModerationQueue; use wcf\data\moderation\queue\ViewableModerationQueue; use wcf\data\object\type\ObjectTypeCache; use wcf\data\user\UserProfile; @@ -57,7 +58,7 @@ class ModerationQueueCommentResponseUserNotificationEvent extends AbstractCommen */ public function checkAccess() { - if (!WCF::getSession()->getPermission('mod.general.canUseModeration') || $this->getModerationQueue() === null) { + if (!WCF::getSession()->getPermission('mod.general.canUseModeration')) { return false; } @@ -161,7 +162,7 @@ class ModerationQueueCommentResponseUserNotificationEvent extends AbstractCommen if (!$this->moderationQueueLoaded) { $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID); - $this->moderationQueue = ViewableModerationQueue::getViewableModerationQueue($comment->objectID); + $this->moderationQueue = new ViewableModerationQueue(new ModerationQueue($comment->objectID)); $this->moderationQueueLoaded = true; } diff --git a/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php index 886cea9917..d207b4f45b 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php @@ -2,6 +2,7 @@ namespace wcf\system\user\notification\event; +use wcf\data\moderation\queue\ModerationQueue; use wcf\data\moderation\queue\ViewableModerationQueue; use wcf\data\object\type\ObjectTypeCache; use wcf\data\user\notification\UserNotification; @@ -51,7 +52,7 @@ class ModerationQueueCommentUserNotificationEvent extends AbstractCommentUserNot */ public function checkAccess() { - if ($this->moderationQueue === null || !WCF::getSession()->getPermission('mod.general.canUseModeration')) { + if (!WCF::getSession()->getPermission('mod.general.canUseModeration')) { return false; } @@ -139,19 +140,16 @@ class ModerationQueueCommentUserNotificationEvent extends AbstractCommentUserNot ) { parent::setObject($notification, $object, $author, $additionalData); - // if the active user has no access, $this->moderationQueue is null - $this->moderationQueue = ViewableModerationQueue::getViewableModerationQueue( - $this->getUserNotificationObject()->objectID + $this->moderationQueue = new ViewableModerationQueue( + new ModerationQueue($this->getUserNotificationObject()->objectID) ); - if ($this->moderationQueue) { - /** @var IModerationQueueHandler $moderationHandler */ - $moderationHandler = ObjectTypeCache::getInstance() - ->getObjectType($this->moderationQueue->objectTypeID) - ->getProcessor(); - $this->languageItemPrefix = $moderationHandler->getCommentNotificationLanguageItemPrefix(); - $this->typeName = $this->getLanguage()->get($moderationHandler->getCommentNotificationTypeNameLanguageItem()); - } + /** @var IModerationQueueHandler $moderationHandler */ + $moderationHandler = ObjectTypeCache::getInstance() + ->getObjectType($this->moderationQueue->objectTypeID) + ->getProcessor(); + $this->languageItemPrefix = $moderationHandler->getCommentNotificationLanguageItemPrefix(); + $this->typeName = $this->getLanguage()->get($moderationHandler->getCommentNotificationTypeNameLanguageItem()); } /** -- 2.20.1