From c29cf7231ebf1c8444fd3f4ce61447a1c371f127 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 26 Nov 2025 14:44:07 -0800 Subject: [PATCH 1/3] Filter out included sites from collection in phpBB4 --- event/main_listener.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/event/main_listener.php b/event/main_listener.php index b1a2f0c..c1006fa 100644 --- a/event/main_listener.php +++ b/event/main_listener.php @@ -104,12 +104,22 @@ public function __construct(auth $auth, config $config, db_text $config_text, la */ public function add_custom_sites($event) { + $is_phpbb4 = phpbb_version_compare(PHPBB_VERSION, '4.0.0', '>='); + $phpbb4_builtins = array_flip([ + 'applepodcasts', 'bluesky', 'bunny', 'mastodon', 'pastebin', 'threads', 'twitter', + ]); + foreach ($this->custom_sites->get_collection() as $site) { - $event['configurator']->MediaEmbed->defaultSites->add( - basename($site, ext::YML), - Yaml::parse(file_get_contents($site)) - ); + $name = basename($site, ext::YML); + + // Skip built-in sites when running phpBB 4 + if ($is_phpbb4 && isset($phpbb4_builtins[$name])) + { + continue; + } + + $event['configurator']->MediaEmbed->defaultSites->add($name, Yaml::parseFile($site)); } } From bcbaf227a2d2d6bb15018678c6ffebb5812c11e3 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 26 Nov 2025 15:04:49 -0800 Subject: [PATCH 2/3] Cover changes in tests --- event/main_listener.php | 4 ++-- tests/event/listener_test.php | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/event/main_listener.php b/event/main_listener.php index c1006fa..f08200d 100644 --- a/event/main_listener.php +++ b/event/main_listener.php @@ -78,7 +78,7 @@ public static function getSubscribedEvents() * Constructor * * @param auth $auth - * @param config $config + * @param config $config * @param db_text $config_text * @param language $language * @param template $template @@ -104,7 +104,7 @@ public function __construct(auth $auth, config $config, db_text $config_text, la */ public function add_custom_sites($event) { - $is_phpbb4 = phpbb_version_compare(PHPBB_VERSION, '4.0.0', '>='); + $is_phpbb4 = phpbb_version_compare($this->config['version'], '4.0.0', '>='); $phpbb4_builtins = array_flip([ 'applepodcasts', 'bluesky', 'bunny', 'mastodon', 'pastebin', 'threads', 'twitter', ]); diff --git a/tests/event/listener_test.php b/tests/event/listener_test.php index a374862..b546447 100644 --- a/tests/event/listener_test.php +++ b/tests/event/listener_test.php @@ -189,10 +189,14 @@ public function test_configure_media_embed($tag, $code, $id, $exists, $parse_url { $this->custom_sites->expects(self::once()) ->method('get_collection') - ->willReturn([__DIR__ . '/../fixtures/sites/ok.yml']); + ->willReturn([ + __DIR__ . '/../fixtures/sites/ok.yml', + __DIR__ . '/../fixtures/sites/bluesky.yml', // this is to test that phpbb4 filtering works + ]); // Update configs with test values $this->config['media_embed_parse_urls'] = $parse_urls; + $this->config['version'] = '4.0.0'; // this is to test that phpbb4 filtering works // Get the s9e configurator $configurator = $this->container From 8e6b3e2a022cb26af0454968303535c106abe9de Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 26 Nov 2025 21:11:24 -0800 Subject: [PATCH 3/3] 4.0.0-a1 --- event/main_listener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event/main_listener.php b/event/main_listener.php index f08200d..07ed675 100644 --- a/event/main_listener.php +++ b/event/main_listener.php @@ -104,7 +104,7 @@ public function __construct(auth $auth, config $config, db_text $config_text, la */ public function add_custom_sites($event) { - $is_phpbb4 = phpbb_version_compare($this->config['version'], '4.0.0', '>='); + $is_phpbb4 = phpbb_version_compare($this->config['version'], '4.0.0-a1', '>='); $phpbb4_builtins = array_flip([ 'applepodcasts', 'bluesky', 'bunny', 'mastodon', 'pastebin', 'threads', 'twitter', ]);