mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Merge pull request #4206 from marc1706/ticket/14519
[ticket/14519] Skip query if all unread notifications are retrieved
This commit is contained in:
commit
7c45ed0733
1 changed files with 3 additions and 1 deletions
|
@ -186,6 +186,7 @@ class manager
|
||||||
if (!$options['count_total'] || $total_count)
|
if (!$options['count_total'] || $total_count)
|
||||||
{
|
{
|
||||||
$rowset = array();
|
$rowset = array();
|
||||||
|
$selected_unread_count = 0;
|
||||||
|
|
||||||
// Get the main notifications
|
// Get the main notifications
|
||||||
$sql = 'SELECT n.*, nt.notification_type_name
|
$sql = 'SELECT n.*, nt.notification_type_name
|
||||||
|
@ -200,11 +201,12 @@ class manager
|
||||||
while ($row = $this->db->sql_fetchrow($result))
|
while ($row = $this->db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$rowset[$row['notification_id']] = $row;
|
$rowset[$row['notification_id']] = $row;
|
||||||
|
$selected_unread_count += (int) !$row['notification_read'];
|
||||||
}
|
}
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
// Get all unread notifications
|
// 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
|
$sql = 'SELECT n.*, nt.notification_type_name
|
||||||
FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
|
FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
|
||||||
|
|
Loading…
Add table
Reference in a new issue