DCausse has uploaded a new change for review. (
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, 16 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/02/404502/1
diff --git a/CirrusSearch.php b/CirrusSearch.php
index 189a1e8..24a4e90 100644
--- a/CirrusSearch.php
+++ b/CirrusSearch.php
@@ -1119,7 +1119,7 @@
* unique across all wiki's sharing an elasticsearch cluster unless
* $wgCirrusSearchMultiWikiIndices is set to true.
*/
-$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..84a6383 100644
--- a/includes/SearchConfig.php
+++ b/includes/SearchConfig.php
@@ -120,7 +120,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 === '__wikiid__'
) {
+ 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: newchange
Gerrit-Change-Id: Ia02f01b373fae4e8a363703ed5201f88f0a7a69d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: DCausse <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits