From 557b47418f70c67a35826fb2ab7688e9ed296f8c Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 20 Mar 2026 12:52:23 -0700 Subject: [PATCH 1/6] Custom vk.com and facebook should be removed in phpbb4 --- event/main_listener.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/event/main_listener.php b/event/main_listener.php index 4e19f2d..73d5560 100644 --- a/event/main_listener.php +++ b/event/main_listener.php @@ -105,7 +105,15 @@ public function __construct(auth $auth, config $config, db_text $config_text, la public function add_custom_sites($event) { $phpbb4_builtins = array_flip([ - 'applepodcasts', 'bluesky', 'bunny', 'mastodon', 'pastebin', 'threads', 'twitter', + 'applepodcasts', + 'bluesky', + 'bunny', + 'facebook', + 'mastodon', + 'pastebin', + 'threads', + 'twitter', + 'vk', ]); foreach ($this->custom_sites->get_collection() as $site) From 45ff63e4a0680c889783fa8ab7601dc9eca7f553 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 20 Mar 2026 12:53:15 -0700 Subject: [PATCH 2/6] Eliminate repeated conditional tests for is_phpbb4 --- event/main_listener.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/event/main_listener.php b/event/main_listener.php index 73d5560..5437da3 100644 --- a/event/main_listener.php +++ b/event/main_listener.php @@ -55,6 +55,9 @@ class main_listener implements EventSubscriberInterface /** @var bool Disable the media tag (bbcode parsing) */ protected $disable_tag = false; + /** @var bool|null Cached result of is_phpbb4() */ + protected $is_phpbb4; + /** * {@inheritDoc} */ @@ -121,7 +124,7 @@ public function add_custom_sites($event) $name = basename($site, ext::YML); // Skip built-in sites when running phpBB 4 - if ($this->is_phpbb4() && isset($phpbb4_builtins[$name])) + if (isset($phpbb4_builtins[$name]) && $this->is_phpbb4()) { continue; } @@ -411,6 +414,11 @@ public function append_agreement() */ private function is_phpbb4() { - return phpbb_version_compare($this->config['version'], '4.0.0-a1', '>='); + if ($this->is_phpbb4 === null) + { + $this->is_phpbb4 = phpbb_version_compare($this->config['version'], '4.0.0-a1', '>='); + } + + return $this->is_phpbb4; } } From e2f82c55d935a8f3726e165e7da44de6292a7a07 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 20 Mar 2026 12:53:42 -0700 Subject: [PATCH 3/6] Remove little coding leftovers --- event/main_listener.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/event/main_listener.php b/event/main_listener.php index 5437da3..5cc81e6 100644 --- a/event/main_listener.php +++ b/event/main_listener.php @@ -188,10 +188,10 @@ public function modify_tag_templates($event) { // force YouTube to use the no cookies until the user starts video playback, and fix referrer policy issues $tag = $event['configurator']->tags['YOUTUBE']; - $tag->template = str_replace(['www.youtube.com'], 'www.youtube-nocookie.com', $tag->template); + $tag->template = str_replace('www.youtube.com', 'www.youtube-nocookie.com', $tag->template); if (!$this->is_phpbb4()) { - $tag->template = str_replace([' allowfullscreen'], ' referrerpolicy="origin" allowfullscreen', $tag->template); + $tag->template = str_replace(' allowfullscreen', ' referrerpolicy="origin" allowfullscreen', $tag->template); } $event['configurator']->finalize(); From 20f334acc1a5d7c50fc05498cc7b18d8630c6b26 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 20 Mar 2026 12:53:58 -0700 Subject: [PATCH 4/6] Update dev version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 19faa44..c361ebd 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "type": "phpbb-extension", "description": "An official phpBB extension that allows users to embed content from allowed sites using a [media] BBCode, or from simply posting a supported URL in plain text.", "homepage": "https://www.phpbb.com/customise/db/extension/mediaembed/", - "version": "2.0.4", + "version": "2.0.5-dev", "license": "GPL-2.0-only", "authors": [ { From 9f55c47d34674cfa119b968a069d18fdf6bf1450 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 20 Mar 2026 21:56:46 -0700 Subject: [PATCH 5/6] Smartly remove custom collections that are already present --- event/main_listener.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/event/main_listener.php b/event/main_listener.php index 5cc81e6..aa08360 100644 --- a/event/main_listener.php +++ b/event/main_listener.php @@ -107,24 +107,12 @@ public function __construct(auth $auth, config $config, db_text $config_text, la */ public function add_custom_sites($event) { - $phpbb4_builtins = array_flip([ - 'applepodcasts', - 'bluesky', - 'bunny', - 'facebook', - 'mastodon', - 'pastebin', - 'threads', - 'twitter', - 'vk', - ]); - foreach ($this->custom_sites->get_collection() as $site) { $name = basename($site, ext::YML); - // Skip built-in sites when running phpBB 4 - if (isset($phpbb4_builtins[$name]) && $this->is_phpbb4()) + // Skip sites already defined as built-ins in phpBB 4 + if ($this->is_phpbb4() && $event['configurator']->MediaEmbed->defaultSites->exists($name)) { continue; } From 65475f5377e537dde51d41c2257e737de0d754eb Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 20 Mar 2026 22:13:10 -0700 Subject: [PATCH 6/6] Revert previous commit --- event/main_listener.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/event/main_listener.php b/event/main_listener.php index aa08360..5cc81e6 100644 --- a/event/main_listener.php +++ b/event/main_listener.php @@ -107,12 +107,24 @@ public function __construct(auth $auth, config $config, db_text $config_text, la */ public function add_custom_sites($event) { + $phpbb4_builtins = array_flip([ + 'applepodcasts', + 'bluesky', + 'bunny', + 'facebook', + 'mastodon', + 'pastebin', + 'threads', + 'twitter', + 'vk', + ]); + foreach ($this->custom_sites->get_collection() as $site) { $name = basename($site, ext::YML); - // Skip sites already defined as built-ins in phpBB 4 - if ($this->is_phpbb4() && $event['configurator']->MediaEmbed->defaultSites->exists($name)) + // Skip built-in sites when running phpBB 4 + if (isset($phpbb4_builtins[$name]) && $this->is_phpbb4()) { continue; }