mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-15 12:05:21 +02:00
[ticket/11403] Use an instance of phpbb_db_sql_insert_buffer instead.
PHPBB3-11403
This commit is contained in:
parent
6910d44154
commit
b156b22f35
@ -390,7 +390,6 @@ class phpbb_notification_manager
|
|||||||
|
|
||||||
$user_ids = array();
|
$user_ids = array();
|
||||||
$notification_objects = $notification_methods = array();
|
$notification_objects = $notification_methods = array();
|
||||||
$new_rows = array();
|
|
||||||
|
|
||||||
// Never send notifications to the anonymous user!
|
// Never send notifications to the anonymous user!
|
||||||
unset($notify_users[ANONYMOUS]);
|
unset($notify_users[ANONYMOUS]);
|
||||||
@ -420,6 +419,8 @@ class phpbb_notification_manager
|
|||||||
$pre_create_data = $notification->pre_create_insert_array($data, $notify_users);
|
$pre_create_data = $notification->pre_create_insert_array($data, $notify_users);
|
||||||
unset($notification);
|
unset($notification);
|
||||||
|
|
||||||
|
$insert_buffer = new phpbb_db_sql_insert_buffer($this->db, $this->notifications_table);
|
||||||
|
|
||||||
// Go through each user so we can insert a row in the DB and then notify them by their desired means
|
// Go through each user so we can insert a row in the DB and then notify them by their desired means
|
||||||
foreach ($notify_users as $user => $methods)
|
foreach ($notify_users as $user => $methods)
|
||||||
{
|
{
|
||||||
@ -427,15 +428,8 @@ class phpbb_notification_manager
|
|||||||
|
|
||||||
$notification->user_id = (int) $user;
|
$notification->user_id = (int) $user;
|
||||||
|
|
||||||
// Store the creation array in our new rows that will be inserted later
|
// Insert notification row using buffer.
|
||||||
$new_rows[] = $notification->create_insert_array($data, $pre_create_data);
|
$insert_buffer->insert($notification->create_insert_array($data, $pre_create_data));
|
||||||
|
|
||||||
// Flush to DB if $new_rows is big enough.
|
|
||||||
if (sizeof($new_rows) > 500)
|
|
||||||
{
|
|
||||||
$this->db->sql_multi_insert($this->notifications_table, $new_rows);
|
|
||||||
$new_rows = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Users are needed to send notifications
|
// Users are needed to send notifications
|
||||||
$user_ids = array_merge($user_ids, $notification->users_to_query());
|
$user_ids = array_merge($user_ids, $notification->users_to_query());
|
||||||
@ -455,10 +449,7 @@ class phpbb_notification_manager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($new_rows))
|
$insert_buffer->flush();
|
||||||
{
|
|
||||||
$this->db->sql_multi_insert($this->notifications_table, $new_rows);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need to load all of the users to send notifications
|
// We need to load all of the users to send notifications
|
||||||
$this->user_loader->load_users($user_ids);
|
$this->user_loader->load_users($user_ids);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user