Skip to content

Commit f239da6

Browse files
authored
Fix version mapping in MediaWikiHostResolver (#1002)
The MediaWiki version string shouldn't contain `-app`. Add test for public function getMwVersionForDomain().
1 parent 563ecd2 commit f239da6

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

app/Services/MediaWikiHostResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class UnknownWikiDomainException extends Exception {}
1717

1818
class MediaWikiHostResolver {
1919
// TODO: Move this mapping to a config file so that MW updates do not require code changes here.
20-
/** @var array<string, string> Map of DB version strings to MediaWiki backend version strings */
20+
/** @var array<string, string> Map of DB version strings to MediaWiki version strings */
2121
private const DB_VERSION_TO_MW_VERSION = [
22-
'mw1.39-wbs1' => '139-app',
23-
'mw1.43-wbs1' => '143-app',
22+
'mw1.39-wbs1' => '139',
23+
'mw1.43-wbs1' => '143',
2424
];
2525

2626
// https://phabricator.wikimedia.org/T409530
@@ -31,7 +31,7 @@ class MediaWikiHostResolver {
3131

3232
public function getBackendHostForDomain(string $domain): string {
3333
// TODO: Move 'backend.default.svc.cluster.local' to an env variable (e.g. PLATFORM_MW_BACKEND_HOST_SUFFIX) for flexibility.
34-
return sprintf('mediawiki-%s-backend.default.svc.cluster.local', $this->getMwVersionForDomain($domain));
34+
return sprintf('mediawiki-%s-app-backend.default.svc.cluster.local', $this->getMwVersionForDomain($domain));
3535
}
3636

3737
public function getMwVersionForDomain(string $domain): string {

tests/Services/MediaWikiHostResolverTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
class MediaWikiHostResolverTest extends TestCase {
1414
use RefreshDatabase;
1515

16+
public function testGetMwVersionForDomain(): void {
17+
$domain = (new Factory)->create()->unique()->text(30);
18+
$this->createWiki($domain, 'mw1.43-wbs1');
19+
$resolver = new MediaWikiHostResolver;
20+
$this->assertSame('143', $resolver->getMwVersionForDomain($domain));
21+
}
22+
1623
public function testResolverRoutesToCorrectHost(): void {
1724
$domain = (new Factory)->create()->unique()->text(30);
1825
$this->createWiki($domain, 'mw1.39-wbs1');

0 commit comments

Comments
 (0)