mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 06:38:52 +00:00
[ticket/17135] Optimize save_queue() method calls
PHPBB-17135
This commit is contained in:
parent
4dd08747e3
commit
3e0270d0cf
4 changed files with 34 additions and 19 deletions
|
@ -265,16 +265,18 @@ class acp_email
|
|||
}
|
||||
|
||||
$errored = !$messenger_method->send() || $errored;
|
||||
if ($use_queue)
|
||||
{
|
||||
$messenger_method->save_queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($email_list);
|
||||
|
||||
$messenger->save_queue();
|
||||
if ($use_queue)
|
||||
{
|
||||
foreach ($messenger_collection_iterator as $messenger_method)
|
||||
{
|
||||
$messenger_method->save_queue();
|
||||
}
|
||||
}
|
||||
|
||||
if ($generate_log_entry)
|
||||
{
|
||||
|
|
|
@ -194,15 +194,15 @@ class acp_inactive
|
|||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
/** @var \phpbb\di\service_collection */
|
||||
$messenger = $phpbb_container->get('messenger.method_collection');
|
||||
$messenger_collection_iterator = $messenger->getIterator();
|
||||
|
||||
if ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
// Send the messages
|
||||
$usernames = $user_ids = array();
|
||||
|
||||
/** @var \phpbb\di\service_collection */
|
||||
$messenger = $phpbb_container->get('messenger.method_collection');
|
||||
$messenger_collection_iterator = $messenger->getIterator();
|
||||
|
||||
do
|
||||
{
|
||||
foreach ($messenger_collection_iterator as $messenger_method)
|
||||
|
@ -219,7 +219,6 @@ class acp_inactive
|
|||
]);
|
||||
|
||||
$messenger_method->send();
|
||||
$messenger_method->save_queue();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,6 +241,11 @@ class acp_inactive
|
|||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
foreach ($messenger_collection_iterator as $messenger_method)
|
||||
{
|
||||
$messenger_method->save_queue();
|
||||
}
|
||||
|
||||
// For remind we really need to redirect, else a refresh can result in more than one reminder
|
||||
$u_action = $this->u_action . "&$u_sort_param&start=$start";
|
||||
$u_action .= ($per_page != $config['topics_per_page']) ? "&users_per_page=$per_page" : '';
|
||||
|
|
|
@ -133,6 +133,8 @@ class ucp_resend
|
|||
WHERE ' . $db->sql_in_set('user_id', $admin_ary[0]['a_user']);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
/** @var \phpbb\di\service_collection */
|
||||
$messenger = $phpbb_container->get('messenger.method_collection');
|
||||
$messenger_collection_iterator = $messenger->getIterator();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
|
@ -151,13 +153,16 @@ class ucp_resend
|
|||
]);
|
||||
|
||||
$messenger_method->send();
|
||||
|
||||
// Save the queue in the messenger method class (has to be called or these messages could be lost)
|
||||
$messenger_method->save_queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Save the queue in the messenger method class (has to be called or these messages could be lost)
|
||||
foreach ($messenger_collection_iterator as $messenger_method)
|
||||
{
|
||||
$messenger_method->save_queue();
|
||||
}
|
||||
}
|
||||
|
||||
$this->update_activation_expiration();
|
||||
|
|
|
@ -86,7 +86,7 @@ abstract class messenger_base extends \phpbb\notification\method\base
|
|||
$user_ids[] = $notification->user_id;
|
||||
}
|
||||
|
||||
// We do not send emails to banned users
|
||||
// We do not notify banned users
|
||||
if (!function_exists('phpbb_get_banned_user_ids'))
|
||||
{
|
||||
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
|
||||
|
@ -96,7 +96,9 @@ abstract class messenger_base extends \phpbb\notification\method\base
|
|||
// Load all the users we need
|
||||
$this->user_loader->load_users(array_diff($user_ids, $banned_users), array(USER_IGNORE));
|
||||
|
||||
// Time to go through the queue and send emails
|
||||
// Time to go through the queue and send notifications
|
||||
$messenger_collection_iterator = $this->messenger->getIterator();
|
||||
|
||||
/** @var type_interface $notification */
|
||||
foreach ($this->queue as $notification)
|
||||
{
|
||||
|
@ -112,7 +114,6 @@ abstract class messenger_base extends \phpbb\notification\method\base
|
|||
continue;
|
||||
}
|
||||
|
||||
$messenger_collection_iterator = $this->messenger->getIterator();
|
||||
foreach ($messenger_collection_iterator as $messenger_method)
|
||||
{
|
||||
if ($messenger_method->get_id() == $notify_method || $notify_method == $messenger_method::NOTIFY_BOTH)
|
||||
|
@ -125,12 +126,15 @@ abstract class messenger_base extends \phpbb\notification\method\base
|
|||
], $notification->get_email_template_variables()));
|
||||
|
||||
$messenger_method->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save the queue in the messenger method class (has to be called or these messages could be lost)
|
||||
foreach ($messenger_collection_iterator as $messenger_method)
|
||||
{
|
||||
$messenger_method->save_queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We're done, empty the queue
|
||||
$this->empty_queue();
|
||||
|
|
Loading…
Add table
Reference in a new issue