Fixed unconfirmed notifications showing in the wrong order
authorAlexander Ebert <ebert@woltlab.com>
Thu, 27 Nov 2014 14:48:31 +0000 (15:48 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 27 Nov 2014 14:48:31 +0000 (15:48 +0100)
wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php

index 30cbc19d575bc3136b50947d6ad9223639313c71..46889a7e6b8a79aefbdb288bb9e9aa8b4301ee55 100644 (file)
@@ -310,9 +310,6 @@ class UserNotificationHandler extends SingletonFactory {
                $notifications = array();
                if ($notificationCount > 0) {
                        $notifications = $this->fetchNotifications(5, 0, 0);
-                       if (!empty($notifications)) {
-                               $notifications = array_reverse($notifications);
-                       }
                }
                
                $count = count($notifications);
@@ -341,9 +338,8 @@ class UserNotificationHandler extends SingletonFactory {
                $conditions = new PreparedStatementConditionBuilder();
                $conditions->add("notification.userID = ?", array(WCF::getUser()->userID));
                
-               $orderBy = 'notification.time DESC';
                if ($filterByConfirmed !== null) {
-                       // fetch the oldest, unconfirmed notifications, order will be reversed using PHP
+                       // consider only unconfirmed notifications
                        if ($filterByConfirmed == 0) {
                                $conditions->add("notification.confirmTime = ?", array(0));
                        }
@@ -351,10 +347,6 @@ class UserNotificationHandler extends SingletonFactory {
                                // consider only notifications marked as confirmed in the past 48 hours (86400 = 1 day)
                                $conditions->add("notification.confirmTime >= ?", array(TIME_NOW - (2 * 86400)));
                        }
-                       
-                       if ($filterByConfirmed = 0) {
-                               $orderBy = 'notification.time ASC';
-                       }
                }
                
                $sql = "SELECT          notification.*, notification_event.eventID, object_type.objectType
@@ -364,7 +356,7 @@ class UserNotificationHandler extends SingletonFactory {
                        LEFT JOIN       wcf".WCF_N."_object_type object_type
                        ON              (object_type.objectTypeID = notification_event.objectTypeID)
                        ".$conditions."
-                       ORDER BY        ".$orderBy;
+                       ORDER BY        notification.time DESC";
                $statement = WCF::getDB()->prepareStatement($sql, $limit, $offset);
                $statement->execute($conditions->getParameters());