From 36527a97b8ddc60b0dffea4d1ad53bc47a0afb1f Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 5 Jun 2024 18:47:57 -0700 Subject: [PATCH] [ticket/17333] Optimize loading web push data only when needed PHPBB-17333 Signed-off-by: Matt Friedman --- phpBB/includes/functions.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8228b29e37..da22c4739d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3873,15 +3873,18 @@ function page_header($page_title = '', $display_online_list = false, $item_id = $template->assign_block_vars('notifications', $notification->prepare_for_display()); } - // Assign notification web push template data (if not done already by ucp_notifications) - if ($config['webpush_dropdown_subscribe'] && $template->retrieve_var('NOTIFICATIONS_WEBPUSH_ENABLE') === null) + // Assign web push template vars globally (if not done already by ucp_notifications) for the dropdown subscribe button + if ($config['webpush_enable'] + && $config['webpush_dropdown_subscribe'] + && $template->retrieve_var('NOTIFICATIONS_WEBPUSH_ENABLE') === null) { $methods = $phpbb_notifications->get_subscription_methods(); - if (isset($methods['notification.method.webpush'])) - { - $form_helper = $phpbb_container->get('form_helper'); + $webpush = $methods['notification.method.webpush'] ?? null; - $template_ary = $methods['notification.method.webpush']['method']->get_ucp_template_data($controller_helper, $form_helper); + if ($webpush) + { + $formHelper = $phpbb_container->get('form_helper'); + $template_ary = $webpush['method']->get_ucp_template_data($controller_helper, $formHelper); $template->assign_vars($template_ary); } }