jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/337884 )
Change subject: Rename and cleanup fetching of all entityNamespaces settings
......................................................................
Rename and cleanup fetching of all entityNamespaces settings
Bug: T157919
Change-Id: I7f26b558e47ea95c7c35eb5abb0641fb769265db
---
M client/config/WikibaseClient.default.php
M client/includes/WikibaseClient.php
M repo/Wikibase.hooks.php
M repo/includes/WikibaseRepo.php
4 files changed, 18 insertions(+), 11 deletions(-)
Approvals:
Aude: Looks good to me, approved
jenkins-bot: Verified
diff --git a/client/config/WikibaseClient.default.php
b/client/config/WikibaseClient.default.php
index 3c4b32e..4db3abd 100644
--- a/client/config/WikibaseClient.default.php
+++ b/client/config/WikibaseClient.default.php
@@ -271,7 +271,7 @@
// if Repo does depend on Client (leads to an infinite
loop in Repo's constructor).
// This is a temporary workaround that should be rather
replaced with something better
// than accessing a static function.
- return
\Wikibase\Repo\WikibaseRepo::getEntityNamespacesSetting();
+ return
\Wikibase\Repo\WikibaseRepo::buildEntityNamespaceConfigurations();
} else {
// XXX: Default to having Items in the main namespace,
and properties in NS 120.
// That is the live setup at wikidata.org, it is NOT
consistent with the example settings!
diff --git a/client/includes/WikibaseClient.php
b/client/includes/WikibaseClient.php
index a4957be..b75c507 100644
--- a/client/includes/WikibaseClient.php
+++ b/client/includes/WikibaseClient.php
@@ -1300,9 +1300,9 @@
}
/**
- * @return int[]
+ * @return int[] An array mapping entity type identifiers to namespace
numbers.
*/
- private function getEntityNamespacesSetting() {
+ private function buildEntityNamespaceConfigurations() {
$namespaces = $this->fixLegacyContentModelSetting(
$this->settings->getSetting( 'entityNamespaces' ),
'entityNamespaces'
@@ -1318,7 +1318,7 @@
public function getEntityNamespaceLookup() {
if ( $this->entityNamespaceLookup === null ) {
$this->entityNamespaceLookup = new
EntityNamespaceLookup(
- $this->getEntityNamespacesSetting()
+ $this->buildEntityNamespaceConfigurations()
);
}
diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php
index c5bc92a..e7bf729 100644
--- a/repo/Wikibase.hooks.php
+++ b/repo/Wikibase.hooks.php
@@ -75,7 +75,7 @@
global $wgContentHandlers;
$wikibaseRepo = WikibaseRepo::getDefaultInstance();
- $namespaces = WikibaseRepo::getEntityNamespacesSetting();
+ $namespaces =
WikibaseRepo::buildEntityNamespaceConfigurations();
// Register entity namespaces.
// Note that $wgExtraNamespaces and $wgNamespaceAliases have
already been processed at this
diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php
index a7f36fa..0961291 100644
--- a/repo/includes/WikibaseRepo.php
+++ b/repo/includes/WikibaseRepo.php
@@ -305,7 +305,7 @@
Hooks::run( 'WikibaseRepoEntityTypes', array(
&$entityTypeDefinitions ) );
$settings = new SettingsArray( $wgWBRepoSettings );
- $settings->setSetting( 'entityNamespaces',
self::getEntityNamespacesSetting() );
+ $settings->setSetting( 'entityNamespaces',
self::buildEntityNamespaceConfigurations() );
$dataRetrievalServices = null;
$clientSettings = null;
@@ -1294,7 +1294,7 @@
* $wgWBRepoSettings['entityNamespaces'] setting.
*/
public function getLocalEntityTypes() {
- return array_keys( $this->settings->getSetting(
'entityNamespaces' ) );
+ return array_keys( $this->getEntityNamespaces() );
}
/**
@@ -1606,19 +1606,26 @@
}
/**
- * @return int[]
+ * @throws MWException in case of a misconfiguration
+ * @return int[] An array mapping entity type identifiers to namespace
numbers.
*/
- public static function getEntityNamespacesSetting() {
+ public static function buildEntityNamespaceConfigurations() {
global $wgWBRepoSettings;
- $namespaces = $wgWBRepoSettings['entityNamespaces'];
+ if ( !is_array( $wgWBRepoSettings['entityNamespaces'] ) ) {
+ throw new MWException( 'Wikibase: Incomplete
configuration: '
+ . '$wgWBRepoSettings[\'entityNamespaces\'] has
to be set to an '
+ . 'array mapping entity types to namespace IDs.
'
+ . 'See Wikibase.example.php for details and
examples.' );
+ }
+ $namespaces = $wgWBRepoSettings['entityNamespaces'];
Hooks::run( 'WikibaseEntityNamespaces', array( &$namespaces ) );
return $namespaces;
}
/**
- * @return int[]
+ * @return int[] An array mapping entity type identifiers to namespace
numbers.
*/
public function getEntityNamespaces() {
return $this->settings->getSetting( 'entityNamespaces' );
--
To view, visit https://gerrit.wikimedia.org/r/337884
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7f26b558e47ea95c7c35eb5abb0641fb769265db
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Aleksey Bekh-Ivanov (WMDE) <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits