Fixed handling of notifications triggered by guests
authorAlexander Ebert <ebert@woltlab.com>
Fri, 27 Jun 2014 09:56:48 +0000 (11:56 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 27 Jun 2014 09:56:48 +0000 (11:56 +0200)
wcfsetup/install/files/lib/data/user/notification/UserNotificationAction.class.php

index ec11526ad1564ff769869c95e3a191e421ab803a..9df95207f7fca06d3ef1b07bc70c56fcb15495fe 100644 (file)
@@ -59,20 +59,22 @@ class UserNotificationAction extends AbstractDatabaseObjectAction {
                }
                
                // insert author
-               $sql = "INSERT INTO     wcf".WCF_N."_user_notification_author
-                                       (notificationID, authorID, time)
-                       VALUES          (?, ?, ?)";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               
-               WCF::getDB()->beginTransaction();
-               foreach ($notifications as $notificationData) {
-                       $statement->execute(array(
-                               $notificationData['object']->notificationID,
-                               ($this->parameters['authorID'] ?: null),
-                               TIME_NOW
-                       ));
+               if ($this->parameters['authorID']) {
+                       $sql = "INSERT INTO     wcf".WCF_N."_user_notification_author
+                                               (notificationID, authorID, time)
+                               VALUES          (?, ?, ?)";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       
+                       WCF::getDB()->beginTransaction();
+                       foreach ($notifications as $notificationData) {
+                               $statement->execute(array(
+                                       $notificationData['object']->notificationID,
+                                       $this->parameters['authorID'],
+                                       TIME_NOW
+                               ));
+                       }
+                       WCF::getDB()->commitTransaction();
                }
-               WCF::getDB()->commitTransaction();
                
                return $notifications;
        }
@@ -112,20 +114,22 @@ class UserNotificationAction extends AbstractDatabaseObjectAction {
                }
                
                // insert author
-               $sql = "INSERT IGNORE INTO      wcf".WCF_N."_user_notification_author
-                                               (notificationID, authorID, time)
-                       VALUES                  (?, ?, ?)";
-               $statement = WCF::getDB()->prepareStatement($sql);
-               
-               WCF::getDB()->beginTransaction();
-               foreach ($notifications as $notificationData) {
-                       $statement->execute(array(
-                               $notificationData['object']->notificationID,
-                               ($this->parameters['authorID'] ?: null),
-                               TIME_NOW
-                       ));
+               if ($this->parameters['authorID']) {
+                       $sql = "INSERT IGNORE INTO      wcf".WCF_N."_user_notification_author
+                                                       (notificationID, authorID, time)
+                               VALUES                  (?, ?, ?)";
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       
+                       WCF::getDB()->beginTransaction();
+                       foreach ($notifications as $notificationData) {
+                               $statement->execute(array(
+                                       $notificationData['object']->notificationID,
+                                       $this->parameters['authorID'],
+                                       TIME_NOW
+                               ));
+                       }
+                       WCF::getDB()->commitTransaction();
                }
-               WCF::getDB()->commitTransaction();
                
                // update trigger count
                $sql = "UPDATE  wcf".WCF_N."_user_notification