Aleksey Bekh-Ivanov (WMDE) has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/338332 )
Change subject: Entity types are not in global scope anymore ...................................................................... Entity types are not in global scope anymore Change-Id: Id27f542a014c8aa145738fbfe51033b822050e0a --- M client/WikibaseClient.php M client/includes/WikibaseClient.php M repo/Wikibase.php M repo/includes/WikibaseRepo.php 4 files changed, 27 insertions(+), 23 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/32/338332/1 diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php index 07df902..e518ea4 100644 --- a/client/WikibaseClient.php +++ b/client/WikibaseClient.php @@ -95,9 +95,6 @@ $wgWBClientDataTypes[$type] = array_merge( $baseDef, $clientDef ); } - // Registry and definition of entity types - $wgWBClientEntityTypes = require __DIR__ . '/../lib/WikibaseLib.entitytypes.php'; - // i18n $wgMessagesDirs['wikibaseclient'] = __DIR__ . '/i18n'; $wgExtensionMessagesFiles['Wikibaseclientalias'] = __DIR__ . '/WikibaseClient.i18n.alias.php'; diff --git a/client/includes/WikibaseClient.php b/client/includes/WikibaseClient.php index 94df27a..5f14a06 100644 --- a/client/includes/WikibaseClient.php +++ b/client/includes/WikibaseClient.php @@ -467,6 +467,13 @@ } /** + * @return array + */ + private static function getDefaultEntityTypes() { + return require __DIR__ . '/../../lib/WikibaseLib.entitytypes.php'; + } + + /** * @return TermBuffer */ public function getTermBuffer() { @@ -695,17 +702,17 @@ * @return WikibaseClient */ private static function newInstance() { - global $wgWBClientSettings, $wgWBClientDataTypes, $wgWBClientEntityTypes; + global $wgWBClientSettings, $wgWBClientDataTypes; - if ( !is_array( $wgWBClientDataTypes ) || !is_array( $wgWBClientEntityTypes ) ) { - throw new MWException( '$wgWBClientDataTypes and $wgWBClientEntityTypes must be arrays. ' + if ( !is_array( $wgWBClientDataTypes ) ) { + throw new MWException( '$wgWBClientDataTypes must be array. ' . 'Maybe you forgot to require WikibaseClient.php in your LocalSettings.php?' ); } $dataTypeDefinitions = $wgWBClientDataTypes; Hooks::run( 'WikibaseClientDataTypes', array( &$dataTypeDefinitions ) ); - $entityTypeDefinitions = $wgWBClientEntityTypes; + $entityTypeDefinitions = self::getDefaultEntityTypes(); Hooks::run( 'WikibaseClientEntityTypes', array( &$entityTypeDefinitions ) ); $settings = new SettingsArray( $wgWBClientSettings ); diff --git a/repo/Wikibase.php b/repo/Wikibase.php index 345958e..1fc72d5 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -76,7 +76,7 @@ global $wgExtensionMessagesFiles, $wgMessagesDirs; global $wgAPIModules, $wgAPIListModules, $wgSpecialPages, $wgHooks; global $wgWBRepoSettings, $wgResourceModules, $wgValueParsers, $wgJobClasses; - global $wgWBRepoDataTypes, $wgWBRepoEntityTypes; + global $wgWBRepoDataTypes; $wgExtensionCredits['wikibase'][] = array( 'path' => __DIR__, @@ -104,17 +104,6 @@ // constants define( 'CONTENT_MODEL_WIKIBASE_ITEM', "wikibase-item" ); define( 'CONTENT_MODEL_WIKIBASE_PROPERTY', "wikibase-property" ); - - // Registry and definition of entity types - $wgWBRepoEntityTypes = require __DIR__ . '/../lib/WikibaseLib.entitytypes.php'; - - $repoEntityTypes = require __DIR__ . '/WikibaseRepo.entitytypes.php'; - - // merge WikibaseRepo.entitytypes.php into $wgWBRepoEntityTypes - foreach ( $repoEntityTypes as $type => $repoDef ) { - $baseDef = isset( $wgWBRepoEntityTypes[$type] ) ? $wgWBRepoEntityTypes[$type] : array(); - $wgWBRepoEntityTypes[$type] = array_merge( $baseDef, $repoDef ); - } // rights // names should be according to other naming scheme diff --git a/repo/includes/WikibaseRepo.php b/repo/includes/WikibaseRepo.php index ee8ce12..a00c6be 100644 --- a/repo/includes/WikibaseRepo.php +++ b/repo/includes/WikibaseRepo.php @@ -291,17 +291,17 @@ * @return self */ private static function newInstance() { - global $wgWBRepoDataTypes, $wgWBRepoEntityTypes, $wgWBRepoSettings; + global $wgWBRepoDataTypes, $wgWBRepoSettings; - if ( !is_array( $wgWBRepoDataTypes ) || !is_array( $wgWBRepoEntityTypes ) ) { - throw new MWException( '$wgWBRepoDataTypes and $wgWBRepoEntityTypes must be arrays. ' + if ( !is_array( $wgWBRepoDataTypes ) ) { + throw new MWException( '$wgWBRepoDataTypes must be array. ' . 'Maybe you forgot to require Wikibase.php in your LocalSettings.php?' ); } $dataTypeDefinitions = $wgWBRepoDataTypes; Hooks::run( 'WikibaseRepoDataTypes', array( &$dataTypeDefinitions ) ); - $entityTypeDefinitions = $wgWBRepoEntityTypes; + $entityTypeDefinitions = self::getDefaultEntityTypes(); Hooks::run( 'WikibaseRepoEntityTypes', array( &$entityTypeDefinitions ) ); $settings = new SettingsArray( $wgWBRepoSettings ); @@ -562,6 +562,17 @@ } /** + * @return array + */ + private static function getDefaultEntityTypes() { + $wgWBRepoEntityTypes = require __DIR__ . '/../../lib/WikibaseLib.entitytypes.php'; + + $repoEntityTypes = require __DIR__ . '/../WikibaseRepo.entitytypes.php'; + + return array_merge_recursive( $wgWBRepoEntityTypes, $repoEntityTypes ); + } + + /** * @return ValueParserFactory */ public function getValueParserFactory() { -- To view, visit https://gerrit.wikimedia.org/r/338332 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id27f542a014c8aa145738fbfe51033b822050e0a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Aleksey Bekh-Ivanov (WMDE) <aleksey.bekh-iva...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits