1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-13 12:22:03 +02:00

[ticket/14519] Skip query if all unread notifications are retrieved

PHPBB3-14519
This commit is contained in:
Marc Alexander 2016-03-08 12:15:21 +01:00
parent f55a61d067
commit 9fcd0b116b

View File

@ -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