jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/404502 )
Change subject: Move wfWikiId resolution for CirrusSearchIndexBaseName into SearchConfig ...................................................................... Move wfWikiId resolution for CirrusSearchIndexBaseName into SearchConfig Should ease the migration to new extension registration Bug: T87892 Change-Id: Ia02f01b373fae4e8a363703ed5201f88f0a7a69d --- M CirrusSearch.php M docs/settings.txt M includes/SearchConfig.php M tests/unit/SearchConfigTest.php 4 files changed, 20 insertions(+), 3 deletions(-) Approvals: Smalyshev: Looks good to me, approved jenkins-bot: Verified diff --git a/CirrusSearch.php b/CirrusSearch.php index 189a1e8..569da30 100644 --- a/CirrusSearch.php +++ b/CirrusSearch.php @@ -1118,8 +1118,9 @@ * The base name of indexes used on this wiki. This value must be * unique across all wiki's sharing an elasticsearch cluster unless * $wgCirrusSearchMultiWikiIndices is set to true. + * The value '__wikiid__' will be resolved at runtime to wfWikiId(). */ -$wgCirrusSearchIndexBaseName = wfWikiID(); +$wgCirrusSearchIndexBaseName = '__wikiid__'; /** * Treat question marks in simple queries as question marks, not diff --git a/docs/settings.txt b/docs/settings.txt index f00900b..321cd67 100644 --- a/docs/settings.txt +++ b/docs/settings.txt @@ -1304,11 +1304,12 @@ ; $wgCirrusSearchIndexBaseName Default: - $wgCirrusSearchIndexBaseName = wfWikiID(); + $wgCirrusSearchIndexBaseName = '__wikiid__'; The base name of indexes used on this wiki. This value must be unique across all wiki's sharing an elasticsearch cluster unless $wgCirrusSearchMultiWikiIndices is set to true. +The value '__wikiid__' will be resolved at runtime to wfWikiId(). ; $wgCirrusSearchStripQuestionMarks diff --git a/includes/SearchConfig.php b/includes/SearchConfig.php index a44443c..8c30d01 100644 --- a/includes/SearchConfig.php +++ b/includes/SearchConfig.php @@ -16,6 +16,9 @@ const PREFIX_IDS = 'CirrusSearchPrefixIds'; const CIRRUS_VAR_PREFIX = 'wgCirrus'; + // Magic word to tell the SearchConfig to translate INDEX_BASE_NAME into wfWikiID() + const WIKI_ID_MAGIC_WORD = '__wikiid__'; + /** @static string[] non cirrus vars to load when loading external wiki config */ private static $nonCirrusVars = [ 'wgLanguageCode', @@ -120,7 +123,11 @@ if ( !$this->source->has( $this->prefix . $name ) ) { return null; } - return $this->source->get( $this->prefix . $name ); + $value = $this->source->get( $this->prefix . $name ); + if ( $name === self::INDEX_BASE_NAME && $value === self::WIKI_ID_MAGIC_WORD ) { + return $this->getWikiId(); + } + return $value; } /** diff --git a/tests/unit/SearchConfigTest.php b/tests/unit/SearchConfigTest.php index 941067f..c418aa7 100644 --- a/tests/unit/SearchConfigTest.php +++ b/tests/unit/SearchConfigTest.php @@ -4,6 +4,7 @@ /** * @group CirrusSearch + * @covers \CirrusSearch\SearchConfig */ class SearchConfigTest extends CirrusTestCase { public function testInterWikiConfig() { @@ -21,4 +22,11 @@ } } } + + public function testIndexBaseName() { + $config = new SearchConfig(); + $this->assertEquals( wfWikiID(), $config->get( 'CirrusSearchIndexBaseName' ) ); + $config = new HashSearchConfig( [ 'CirrusSearchIndexBaseName' => 'foobar' ] ); + $this->assertEquals( 'foobar', $config->get( 'CirrusSearchIndexBaseName' ) ); + } } -- To view, visit https://gerrit.wikimedia.org/r/404502 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia02f01b373fae4e8a363703ed5201f88f0a7a69d Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: master Gerrit-Owner: DCausse <dcau...@wikimedia.org> Gerrit-Reviewer: Cindy-the-browser-test-bot <bernhardsone...@gmail.com> Gerrit-Reviewer: DCausse <dcau...@wikimedia.org> Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org> Gerrit-Reviewer: Gehel <guillaume.leder...@wikimedia.org> Gerrit-Reviewer: Smalyshev <smalys...@wikimedia.org> Gerrit-Reviewer: Tjones <tjo...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits