Ignore guests when marking comment notifications as confirmed
authorMatthias Schmidt <gravatronics@live.com>
Mon, 6 May 2019 17:17:28 +0000 (19:17 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 6 May 2019 17:17:28 +0000 (19:17 +0200)
See #2835

wcfsetup/install/files/lib/system/comment/CommentHandler.class.php

index 261b6f5771ffa751930fbe4add4b72d302523fce..db53f5705891e2f22767c4dce048fa4880800aab 100644 (file)
@@ -245,6 +245,11 @@ class CommentHandler extends SingletonFactory {
         * @since       5.2
         */
        public function markNotificationsAsConfirmed($objectType, array $objectIDs, $time = TIME_NOW) {
+               // notifications are only relevant for logged-in users
+               if (!WCF::getUser()->userID) {
+                       return;
+               }
+               
                if ($this->getObjectTypeID($objectType) === null) {
                        throw new \InvalidArgumentException("Unknown comment object type '{$objectType}'.");
                }
@@ -448,6 +453,11 @@ class CommentHandler extends SingletonFactory {
         * @since       5.2
         */
        public function markNotificationsAsConfirmedForComments($objectType, array $comments) {
+               // notifications are only relevant for logged-in users
+               if (!WCF::getUser()->userID) {
+                       return;
+               }
+               
                if ($this->getObjectTypeID($objectType) === null) {
                        throw new \InvalidArgumentException("Unknown comment object type '{$objectType}'.");
                }
@@ -615,6 +625,11 @@ class CommentHandler extends SingletonFactory {
         * @since       5.2
         */
        public function markNotificationsAsConfirmedForResponses($objectType, array $responses) {
+               // notifications are only relevant for logged-in users
+               if (!WCF::getUser()->userID) {
+                       return;
+               }
+               
                if ($this->getObjectTypeID($objectType) === null) {
                        throw new \InvalidArgumentException("Unknown comment object type '{$objectType}'.");
                }