Fix issue in RSS feed for notifications
authorMarcel Werk <burntime@woltlab.com>
Thu, 29 Aug 2024 09:17:45 +0000 (11:17 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 29 Aug 2024 09:17:45 +0000 (11:17 +0200)
The first element in the array did not necessarily have the index `0`.

wcfsetup/install/files/lib/page/NotificationRssFeedPage.class.php

index f2ff35b4aa2f637183e14143d8305794a6bbbc35..e29f856e52307f05e0dc4fe241af74f0fc34b574 100644 (file)
@@ -38,14 +38,16 @@ class NotificationRssFeedPage extends AbstractRssFeedPage
         $feed->channel($channel);
 
         $notifications = UserNotificationHandler::getInstance()->getNotifications(20);
-        if ($notifications['notifications'] !== []) {
-            $channel->lastBuildDateFromTimestamp($notifications['notifications'][0]['time']);
-        }
-
+        $isFirstEntry = true;
         foreach ($notifications['notifications'] as $notification) {
             $event = $notification['event'];
             \assert($event instanceof AbstractUserNotificationEvent);
 
+            if ($isFirstEntry) {
+                $channel->lastBuildDateFromTimestamp($event->getTime());
+                $isFirstEntry = false;
+            }
+
             $item = new RssFeedItem();
             $item
                 ->title($event->getTitle())