Fix authors for guest-only triggered test notifications
authorMatthias Schmidt <gravatronics@live.com>
Fri, 4 Aug 2017 17:57:19 +0000 (19:57 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 4 Aug 2017 17:57:24 +0000 (19:57 +0200)
wcfsetup/install/files/lib/system/user/notification/TestableUserNotificationEventHandler.class.php

index 40a09d10f5877bc6eb8d888b745edfc37f81ffd9..1b7ab6468e2cbee0f1c5b1a60947716939359833 100644 (file)
@@ -224,6 +224,8 @@ class TestableUserNotificationEventHandler extends SingletonFactory {
                        $maxGuestCount = 0;
                }
                
+               $unknownAuthor = UserProfile::getGuestUserProfile('Unknown Author');
+               
                $events = [];
                foreach (LanguageFactory::getInstance()->getLanguages() as $language) {
                        for ($authorCount = $minAuthorCount; $authorCount <= $maxAuthorCount; $authorCount++) {
@@ -242,13 +244,20 @@ class TestableUserNotificationEventHandler extends SingletonFactory {
                                                        'language' => $language,
                                                        'timesTriggered' => $authorCount
                                                ]));
+                                               
                                                $event->setObject(
                                                        $this->getUserNotification($firstAuthor, $authorCount, $guestCount, $additionalData),
                                                        $object,
-                                                       $firstAuthor,
+                                                       $authorCount ? $firstAuthor : $unknownAuthor,
                                                        $additionalData
                                                );
-                                               $event->setAuthors(array_slice($authors, 0, $authorCount, true));
+                                               
+                                               if ($authorCount) {
+                                                       $event->setAuthors(array_slice($authors, 0, $authorCount, true));
+                                               }
+                                               else {
+                                                       $event->setAuthors([$unknownAuthor]);
+                                               }
                                                
                                                $events[] = $event;
                                        }