diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-04-11 12:44:31 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-04-25 11:52:20 +0200 |
commit | 418747ed341f0c4d2f1d1c1b5ea177fadde9ce7e (patch) | |
tree | ac5e923c2dc1fedfe888f04b59bae26b782b0895 /phpBB/phpbb/notification/type/post.php | |
parent | 92db22c8827abfad8615b0537fdc6fd89ab4203f (diff) | |
download | forums-418747ed341f0c4d2f1d1c1b5ea177fadde9ce7e.tar forums-418747ed341f0c4d2f1d1c1b5ea177fadde9ce7e.tar.gz forums-418747ed341f0c4d2f1d1c1b5ea177fadde9ce7e.tar.bz2 forums-418747ed341f0c4d2f1d1c1b5ea177fadde9ce7e.tar.xz forums-418747ed341f0c4d2f1d1c1b5ea177fadde9ce7e.zip |
[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
Diffstat (limited to 'phpBB/phpbb/notification/type/post.php')
-rw-r--r-- | phpBB/phpbb/notification/type/post.php | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 7d4bc06879..987651887f 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -152,10 +152,14 @@ class post extends \phpbb\notification\type\base unset($notify_users[$row['user_id']]); $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row); - $sql = 'UPDATE ' . $this->notifications_table . ' - SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . ' - WHERE notification_id = ' . $row['notification_id']; - $this->db->sql_query($sql); + $update_responders = $notification->add_responders($post); + if (!empty($update_responders)) + { + $sql = 'UPDATE ' . $this->notifications_table . ' + SET ' . $this->db->sql_build_array('UPDATE', $update_responders) . ' + WHERE notification_id = ' . $row['notification_id']; + $this->db->sql_query($sql); + } } $this->db->sql_freeresult($result); @@ -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 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'); @@ -404,7 +408,7 @@ class post extends \phpbb\notification\type\base // Do not add them as a responder multiple times 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); - return array('notification_data' => serialize($this->get_data(false))); + $serialized_data = serialize($this->get_data(false)); + return array('notification_data' => $serialized_data); } } |