Skip to content

Commit 1ec4435

Browse files
committed
Adjust code, also do not reload language files if not needed.
1 parent aa7897e commit 1ec4435

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

notification/method/webpush.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,17 @@ public function notify()
146146
{
147147
$insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->notification_webpush_table);
148148

149-
// Load all users we want to notify
150-
$notify_users = $this->load_receivers();
149+
// Load all users data we want to notify
150+
$notify_users = $this->load_recipients_data();
151151

152152
/** @var type_interface $notification */
153153
foreach ($this->queue as $notification)
154154
{
155155
$data = $notification->get_insert_array();
156156

157157
// Choose receiving user's language
158-
$user = $this->user_loader->get_user($data['user_id']);
159-
$this->language->set_user_language($user['user_lang'], true);
158+
$recipient_data = $this->user_loader->get_user($notification->user_id);
159+
$this->language->set_user_language($recipient_data['user_lang'], $this->language->get_used_language() !== $recipient_data['user_lang']);
160160

161161
$data += [
162162
'push_data' => json_encode([
@@ -177,7 +177,7 @@ public function notify()
177177
$insert_buffer->flush();
178178

179179
// Restore current user's language
180-
$this->language->set_user_language($this->user->data['user_lang'], true);
180+
$this->language->set_user_language($this->user->data['user_lang'], $this->language->get_used_language() !== $this->user->data['user_lang']);
181181

182182
$this->notify_using_webpush($notify_users);
183183

@@ -524,7 +524,7 @@ protected function set_endpoint_padding(\Minishlink\WebPush\WebPush $web_push, s
524524
*
525525
* @return array Array of user ids to notify
526526
*/
527-
protected function load_receivers(): array
527+
protected function load_recipients_data(): array
528528
{
529529
$notify_users = $user_ids = [];
530530
foreach ($this->queue as $notification)

0 commit comments

Comments
 (0)