Fix determination of article owner userID for article comment notifications
authorMatthias Schmidt <gravatronics@live.com>
Sat, 24 Nov 2018 15:01:01 +0000 (16:01 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 24 Nov 2018 15:01:01 +0000 (16:01 +0100)
See #2649

wcfsetup/install/files/lib/system/user/notification/object/type/ArticleCommentUserNotificationObjectType.class.php

index a2d5e9039ab6cd7eae242836cfa40bfda2550aa2..240069da4dd3456acfd9b437013f5633abb300bb 100644 (file)
@@ -34,13 +34,14 @@ class ArticleCommentUserNotificationObjectType extends AbstractUserNotificationO
         * @inheritDoc
         */
        public function getOwnerID($objectID) {
-               $sql = "SELECT  objectID
-                       FROM    wcf".WCF_N."_comment
-                       WHERE   commentID = ?";
+               $sql = "SELECT          article.userID
+                       FROM            wcf".WCF_N."_comment comment
+                       LEFT JOIN       wcf".WCF_N."_article article
+                       ON              (article.articleID = comment.objectID)
+                       WHERE           comment.commentID = ?";
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute([$objectID]);
-               $row = $statement->fetchArray();
                
-               return ($row ? $row['objectID'] : 0);
+               return $statement->fetchSingleColumn() ?: 0;
        }
 }