From 9fcd0b116b4a5340f8743df53235e1c639204989 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 8 Mar 2016 12:15:21 +0100 Subject: [ticket/14519] Skip query if all unread notifications are retrieved PHPBB3-14519 --- phpBB/phpbb/notification/manager.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/phpbb') diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index db92170dd8..b1b096d41d 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -186,6 +186,7 @@ class manager if (!$options['count_total'] || $total_count) { $rowset = array(); + $selected_unread_count = 0; // Get the main notifications $sql = 'SELECT n.*, nt.notification_type_name @@ -200,11 +201,12 @@ class manager while ($row = $this->db->sql_fetchrow($result)) { $rowset[$row['notification_id']] = $row; + $selected_unread_count += (int) !$row['notification_read']; } $this->db->sql_freeresult($result); // Get all unread notifications - if ($unread_count && $options['all_unread'] && !empty($rowset)) + if ($selected_unread_count < $unread_count && $options['all_unread'] && !empty($rowset)) { $sql = 'SELECT n.*, nt.notification_type_name FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt -- cgit v1.2.1