From c96e0c1027bf041c7bbb1d63833dff927059ffcf Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 25 Oct 2025 20:48:52 -0700 Subject: [PATCH 1/6] Add meta tag to make Chrome happy --- styles/all/template/event/overall_header_head_append.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/styles/all/template/event/overall_header_head_append.html b/styles/all/template/event/overall_header_head_append.html index 00c8172..790dcda 100644 --- a/styles/all/template/event/overall_header_head_append.html +++ b/styles/all/template/event/overall_header_head_append.html @@ -1,3 +1,6 @@ + + + From 74690c03690630aaa3f5dbad9261931183f62c6c Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 25 Oct 2025 20:50:20 -0700 Subject: [PATCH 2/6] Revisitng manifest scope and start_url paths --- controller/manifest.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/controller/manifest.php b/controller/manifest.php index 634d880..8a2019f 100644 --- a/controller/manifest.php +++ b/controller/manifest.php @@ -48,20 +48,25 @@ public function __construct(config $config, path_helper $path_helper, user $user */ public function handle(): JsonResponse { - $board_path = $this->config['force_server_vars'] ? $this->config['script_path'] : $this->path_helper->get_web_root_path(); + // Get the board URL and extract the path component $board_url = generate_board_url(); + $board_path = $this->config['force_server_vars'] ? $this->config['script_path'] : (parse_url($board_url)['path'] ?? ''); + + // Ensure path ends with '/' for PWA scope + $scope = rtrim($board_path, '/') . '/'; + $start_url = $scope; // Emoji fixer-uppers $sitename = ext::decode_entities($this->config['sitename'], ENT_QUOTES); - $pwa_short_name = ext::decode_entities($this->config['pwa_short_name'], ENT_QUOTES); + $sitename_short = ext::decode_entities($this->config['pwa_short_name'], ENT_QUOTES); $manifest = [ 'name' => $sitename, - 'short_name' => $pwa_short_name ?: utf8_substr($sitename, 0, 12), + 'short_name' => $sitename_short ?: utf8_substr($sitename, 0, 12), 'display' => 'standalone', 'orientation' => 'portrait', - 'start_url' => $board_path, - 'scope' => $board_path, + 'start_url' => $start_url, + 'scope' => $scope, ]; if (!empty($this->config['pwa_icon_small']) && !empty($this->config['pwa_icon_large'])) From dcac6ce75839927ec6281eca18b1c8f6390eb4ca Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 25 Oct 2025 20:50:35 -0700 Subject: [PATCH 3/6] Add iOS status bar back --- styles/all/template/event/overall_header_head_append.html | 1 + 1 file changed, 1 insertion(+) diff --git a/styles/all/template/event/overall_header_head_append.html b/styles/all/template/event/overall_header_head_append.html index 790dcda..de18eab 100644 --- a/styles/all/template/event/overall_header_head_append.html +++ b/styles/all/template/event/overall_header_head_append.html @@ -3,6 +3,7 @@ + From 70289ef83953643ac3cf26b94d6585f576f59bfb Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 25 Oct 2025 21:11:12 -0700 Subject: [PATCH 4/6] Fix tests --- tests/controller/controller_manifest_test.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/controller/controller_manifest_test.php b/tests/controller/controller_manifest_test.php index be9d3ba..abeda2e 100644 --- a/tests/controller/controller_manifest_test.php +++ b/tests/controller/controller_manifest_test.php @@ -52,7 +52,7 @@ protected function setUp(): void public function manifest_data() { return [ - 'using web root path' => [ + 'using board url root path' => [ [ 'force_server_vars' => false, 'script_path' => '', @@ -64,14 +64,14 @@ public function manifest_data() 'short_name' => 'yourdomain', 'display' => 'standalone', 'orientation' => 'portrait', - 'start_url' => './phpBB/', - 'scope' => './phpBB/', + 'start_url' => '/', + 'scope' => '/', ], ], 'using script path' => [ [ 'force_server_vars' => true, - 'script_path' => '/', + 'script_path' => '/foo/', 'sitename' => 'yourdomain.com', 'pwa_short_name' => 'yourdomain', ], @@ -80,8 +80,8 @@ public function manifest_data() 'short_name' => 'yourdomain', 'display' => 'standalone', 'orientation' => 'portrait', - 'start_url' => '/', - 'scope' => '/', + 'start_url' => '/foo/', + 'scope' => '/foo/', ], ], 'with shortname' => [ @@ -94,8 +94,8 @@ public function manifest_data() 'short_name' => 'testdomain', 'display' => 'standalone', 'orientation' => 'portrait', - 'start_url' => './phpBB/', - 'scope' => './phpBB/', + 'start_url' => '/', + 'scope' => '/', ], ], 'without shortname' => [ @@ -108,8 +108,8 @@ public function manifest_data() 'short_name' => 'testdomain.c', 'display' => 'standalone', 'orientation' => 'portrait', - 'start_url' => './phpBB/', - 'scope' => './phpBB/', + 'start_url' => '/', + 'scope' => '/', ], ], 'with icons' => [ @@ -124,8 +124,8 @@ public function manifest_data() 'short_name' => '', 'display' => 'standalone', 'orientation' => 'portrait', - 'start_url' => './phpBB/', - 'scope' => './phpBB/', + 'start_url' => '/', + 'scope' => '/', 'icons' => [ [ 'src' => 'http://images/site_icons/foo_sm.png', From 349c113e9509ae1509bbe97dc3e5f75ce07945f9 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 25 Oct 2025 21:11:25 -0700 Subject: [PATCH 5/6] Watch out for windows paths --- controller/manifest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/manifest.php b/controller/manifest.php index 8a2019f..a94804c 100644 --- a/controller/manifest.php +++ b/controller/manifest.php @@ -53,7 +53,7 @@ public function handle(): JsonResponse $board_path = $this->config['force_server_vars'] ? $this->config['script_path'] : (parse_url($board_url)['path'] ?? ''); // Ensure path ends with '/' for PWA scope - $scope = rtrim($board_path, '/') . '/'; + $scope = rtrim($board_path, '/\\') . '/'; $start_url = $scope; // Emoji fixer-uppers From 826d52ad232418ee68782847b10bf398e6cee6a8 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 26 Oct 2025 07:17:33 -0700 Subject: [PATCH 6/6] Remove unused path helpers --- config/services.yml | 2 -- controller/manifest.php | 8 +------- notification/method/webpush.php | 8 +------- tests/controller/controller_manifest_test.php | 15 +++------------ tests/event/listener_test.php | 6 ------ .../notification_method_webpush_test.php | 15 --------------- 6 files changed, 5 insertions(+), 49 deletions(-) diff --git a/config/services.yml b/config/services.yml index 5a3eb10..e21730d 100644 --- a/config/services.yml +++ b/config/services.yml @@ -33,7 +33,6 @@ services: - '@log' - '@user_loader' - '@user' - - '@path_helper' - '%core.root_path%' - '%core.php_ext%' - '%tables.phpbb.wpn.notification_push%' @@ -62,5 +61,4 @@ services: class: phpbb\webpushnotifications\controller\manifest arguments: - '@config' - - '@path_helper' - '@user' diff --git a/controller/manifest.php b/controller/manifest.php index a94804c..0201769 100644 --- a/controller/manifest.php +++ b/controller/manifest.php @@ -11,7 +11,6 @@ namespace phpbb\webpushnotifications\controller; use phpbb\config\config; -use phpbb\path_helper; use phpbb\user; use phpbb\webpushnotifications\ext; use Symfony\Component\HttpFoundation\JsonResponse; @@ -21,9 +20,6 @@ class manifest /** @var config */ protected $config; - /** @var path_helper */ - protected $path_helper; - /** @var user */ protected $user; @@ -31,13 +27,11 @@ class manifest * Constructor for webpush controller * * @param config $config - * @param path_helper $path_helper * @param user $user */ - public function __construct(config $config, path_helper $path_helper, user $user) + public function __construct(config $config, user $user) { $this->config = $config; - $this->path_helper = $path_helper; $this->user = $user; } diff --git a/notification/method/webpush.php b/notification/method/webpush.php index c1756c4..311eeb0 100644 --- a/notification/method/webpush.php +++ b/notification/method/webpush.php @@ -17,7 +17,6 @@ use phpbb\log\log_interface; use phpbb\notification\method\base; use phpbb\notification\type\type_interface; -use phpbb\path_helper; use phpbb\user; use phpbb\user_loader; use phpbb\webpushnotifications\form\form_helper; @@ -44,9 +43,6 @@ class webpush extends base implements extended_method_interface /** @var user */ protected $user; - /** @var path_helper */ - protected $path_helper; - /** @var string */ protected $phpbb_root_path; @@ -73,13 +69,12 @@ class webpush extends base implements extended_method_interface * @param log_interface $log * @param user_loader $user_loader * @param user $user - * @param path_helper $path_helper * @param string $phpbb_root_path * @param string $php_ext * @param string $notification_webpush_table * @param string $push_subscriptions_table */ - public function __construct(config $config, driver_interface $db, log_interface $log, user_loader $user_loader, user $user, path_helper $path_helper, + public function __construct(config $config, driver_interface $db, log_interface $log, user_loader $user_loader, user $user, string $phpbb_root_path, string $php_ext, string $notification_webpush_table, string $push_subscriptions_table) { $this->config = $config; @@ -87,7 +82,6 @@ public function __construct(config $config, driver_interface $db, log_interface $this->log = $log; $this->user_loader = $user_loader; $this->user = $user; - $this->path_helper = $path_helper; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $this->notification_webpush_table = $notification_webpush_table; diff --git a/tests/controller/controller_manifest_test.php b/tests/controller/controller_manifest_test.php index abeda2e..8dac316 100644 --- a/tests/controller/controller_manifest_test.php +++ b/tests/controller/controller_manifest_test.php @@ -15,14 +15,12 @@ class controller_manifest_test extends \phpbb_test_case { protected $config; - protected $path_helper; protected $user; protected $manifest; protected function setUp(): void { - global $phpbb_root_path, $phpEx; - global $config, $user, $request, $symfony_request; + global $config, $user, $phpbb_root_path, $phpEx; parent::setUp(); @@ -38,15 +36,8 @@ protected function setUp(): void $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $language = new \phpbb\language\language($lang_loader); $user = $this->user = new \phpbb\user($language, '\phpbb\datetime'); - $symfony_request = $this->createMock(\phpbb\symfony_request::class); - $request = $this->request = $this->createMock(\phpbb\request\request_interface::class); - $this->path_helper = new \phpbb\path_helper($symfony_request, new \phpbb\filesystem\filesystem(), $this->request, $phpbb_root_path, $phpEx); - - $this->manifest = new \phpbb\webpushnotifications\controller\manifest( - $this->config, - $this->path_helper, - $this->user - ); + + $this->manifest = new \phpbb\webpushnotifications\controller\manifest($this->config, $this->user); } public function manifest_data() diff --git a/tests/event/listener_test.php b/tests/event/listener_test.php index b6de772..162fe4b 100644 --- a/tests/event/listener_test.php +++ b/tests/event/listener_test.php @@ -95,11 +95,6 @@ protected function setUp(): void $this->user ); - $path_helper = $this->getMockBuilder('\phpbb\path_helper') - ->disableOriginalConstructor() - ->setMethods(array()) - ->getMock(); - $this->notifications = $this->getMockBuilder('\phpbb\notification\manager') ->disableOriginalConstructor() ->getMock(); @@ -113,7 +108,6 @@ protected function setUp(): void new \phpbb\log\dummy(), $user_loader, $this->user, - $path_helper, $phpbb_root_path, $phpEx, 'phpbb_wpn_notification_push', diff --git a/tests/notification/notification_method_webpush_test.php b/tests/notification/notification_method_webpush_test.php index d5b9450..3c472c2 100644 --- a/tests/notification/notification_method_webpush_test.php +++ b/tests/notification/notification_method_webpush_test.php @@ -128,19 +128,6 @@ protected function setUp(): void $phpEx ); - $request = new \phpbb_mock_request; - $symfony_request = new \phpbb\symfony_request( - $request - ); - $filesystem = new \phpbb\filesystem\filesystem(); - $phpbb_path_helper = new \phpbb\path_helper( - $symfony_request, - $filesystem, - $request, - $phpbb_root_path, - $phpEx - ); - $log_table = 'phpbb_log'; $this->log = new \phpbb\log\log($this->db, $user, $auth, $this->phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, $log_table); @@ -158,7 +145,6 @@ protected function setUp(): void $phpbb_container->set('log', $this->log); $phpbb_container->set('text_formatter.utils', new \phpbb\textformatter\s9e\utils()); $phpbb_container->set('dispatcher', $this->phpbb_dispatcher); - $phpbb_container->set('path_helper', $phpbb_path_helper); $phpbb_container->setParameter('core.root_path', $phpbb_root_path); $phpbb_container->setParameter('core.php_ext', $phpEx); $phpbb_container->setParameter('tables.notifications', 'phpbb_notifications'); @@ -174,7 +160,6 @@ protected function setUp(): void $phpbb_container->get('log'), $phpbb_container->get('user_loader'), $phpbb_container->get('user'), - $phpbb_container->get('path_helper'), $phpbb_root_path, $phpEx, $phpbb_container->getParameter('tables.phpbb.wpn.notification_push'),