mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/12371] Do not update the notification entry unneccessarily
When the data did not change, we also don't have to run the query at all. PHPBB3-12371
This commit is contained in:
parent
92db22c882
commit
418747ed34
2 changed files with 20 additions and 11 deletions
|
@ -110,11 +110,15 @@ class bookmark extends \phpbb\notification\type\post
|
||||||
unset($notify_users[$row['user_id']]);
|
unset($notify_users[$row['user_id']]);
|
||||||
|
|
||||||
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
|
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
|
||||||
|
$update_responders = $notification->add_responders($post);
|
||||||
|
if (!empty($update_responders))
|
||||||
|
{
|
||||||
$sql = 'UPDATE ' . $this->notifications_table . '
|
$sql = 'UPDATE ' . $this->notifications_table . '
|
||||||
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
|
SET ' . $this->db->sql_build_array('UPDATE', $update_responders) . '
|
||||||
WHERE notification_id = ' . $row['notification_id'];
|
WHERE notification_id = ' . $row['notification_id'];
|
||||||
$this->db->sql_query($sql);
|
$this->db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
return $notify_users;
|
return $notify_users;
|
||||||
|
|
|
@ -152,11 +152,15 @@ class post extends \phpbb\notification\type\base
|
||||||
unset($notify_users[$row['user_id']]);
|
unset($notify_users[$row['user_id']]);
|
||||||
|
|
||||||
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
|
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
|
||||||
|
$update_responders = $notification->add_responders($post);
|
||||||
|
if (!empty($update_responders))
|
||||||
|
{
|
||||||
$sql = 'UPDATE ' . $this->notifications_table . '
|
$sql = 'UPDATE ' . $this->notifications_table . '
|
||||||
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
|
SET ' . $this->db->sql_build_array('UPDATE', $update_responders) . '
|
||||||
WHERE notification_id = ' . $row['notification_id'];
|
WHERE notification_id = ' . $row['notification_id'];
|
||||||
$this->db->sql_query($sql);
|
$this->db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
return $notify_users;
|
return $notify_users;
|
||||||
|
@ -392,7 +396,7 @@ class post extends \phpbb\notification\type\base
|
||||||
// Do not add them as a responder if they were the original poster that created the notification
|
// Do not add them as a responder if they were the original poster that created the notification
|
||||||
if ($this->get_data('poster_id') == $post['poster_id'])
|
if ($this->get_data('poster_id') == $post['poster_id'])
|
||||||
{
|
{
|
||||||
return array('notification_data' => serialize($this->get_data(false)));
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$responders = $this->get_data('responders');
|
$responders = $this->get_data('responders');
|
||||||
|
@ -404,7 +408,7 @@ class post extends \phpbb\notification\type\base
|
||||||
// Do not add them as a responder multiple times
|
// Do not add them as a responder multiple times
|
||||||
if ($responder['poster_id'] == $post['poster_id'])
|
if ($responder['poster_id'] == $post['poster_id'])
|
||||||
{
|
{
|
||||||
return array('notification_data' => serialize($this->get_data(false)));
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,6 +419,7 @@ class post extends \phpbb\notification\type\base
|
||||||
|
|
||||||
$this->set_data('responders', $responders);
|
$this->set_data('responders', $responders);
|
||||||
|
|
||||||
return array('notification_data' => serialize($this->get_data(false)));
|
$serialized_data = serialize($this->get_data(false));
|
||||||
|
return array('notification_data' => $serialized_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue