Skip to content

Commit 13250b5

Browse files
authored
Merge pull request #120 from iMattPro/updates
Filter phpBB4 included sites
2 parents 421fb61 + 8e6b3e2 commit 13250b5

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

event/main_listener.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static function getSubscribedEvents()
7878
* Constructor
7979
*
8080
* @param auth $auth
81-
* @param config $config
81+
* @param config $config
8282
* @param db_text $config_text
8383
* @param language $language
8484
* @param template $template
@@ -104,12 +104,22 @@ public function __construct(auth $auth, config $config, db_text $config_text, la
104104
*/
105105
public function add_custom_sites($event)
106106
{
107+
$is_phpbb4 = phpbb_version_compare($this->config['version'], '4.0.0-a1', '>=');
108+
$phpbb4_builtins = array_flip([
109+
'applepodcasts', 'bluesky', 'bunny', 'mastodon', 'pastebin', 'threads', 'twitter',
110+
]);
111+
107112
foreach ($this->custom_sites->get_collection() as $site)
108113
{
109-
$event['configurator']->MediaEmbed->defaultSites->add(
110-
basename($site, ext::YML),
111-
Yaml::parse(file_get_contents($site))
112-
);
114+
$name = basename($site, ext::YML);
115+
116+
// Skip built-in sites when running phpBB 4
117+
if ($is_phpbb4 && isset($phpbb4_builtins[$name]))
118+
{
119+
continue;
120+
}
121+
122+
$event['configurator']->MediaEmbed->defaultSites->add($name, Yaml::parseFile($site));
113123
}
114124
}
115125

tests/event/listener_test.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,14 @@ public function test_configure_media_embed($tag, $code, $id, $exists, $parse_url
189189
{
190190
$this->custom_sites->expects(self::once())
191191
->method('get_collection')
192-
->willReturn([__DIR__ . '/../fixtures/sites/ok.yml']);
192+
->willReturn([
193+
__DIR__ . '/../fixtures/sites/ok.yml',
194+
__DIR__ . '/../fixtures/sites/bluesky.yml', // this is to test that phpbb4 filtering works
195+
]);
193196

194197
// Update configs with test values
195198
$this->config['media_embed_parse_urls'] = $parse_urls;
199+
$this->config['version'] = '4.0.0'; // this is to test that phpbb4 filtering works
196200

197201
// Get the s9e configurator
198202
$configurator = $this->container

0 commit comments

Comments
 (0)