Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/72938


Change subject: Get rid of some global scope assumptions in repo config
......................................................................

Get rid of some global scope assumptions in repo config

Change-Id: I54ffac4ed8d8be7e140f23ee52289e28a96677b0
---
M repo/config/Wikibase.example.php
M repo/config/Wikibase.experimental.php
2 files changed, 57 insertions(+), 51 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/38/72938/1

diff --git a/repo/config/Wikibase.example.php b/repo/config/Wikibase.example.php
index 07598c8..ca54daa 100644
--- a/repo/config/Wikibase.example.php
+++ b/repo/config/Wikibase.example.php
@@ -34,40 +34,45 @@
        die( 'Not an entry point.' );
 }
 
-$wgContentHandlerUseDB = true;
+call_user_func( function() {
+       global $wgContentHandlerUseDB, $baseNs, $wgExtraNamespaces, 
$wgWBRepoSettings;
+       global $wgNamespacesToBeSearchedDefault, $wgGroupPermissions;
 
-$baseNs = 120;
+       $wgContentHandlerUseDB = true;
 
-// Define custom namespaces. Use these exact constant names.
-define( 'WB_NS_ITEM', $baseNs );
-define( 'WB_NS_ITEM_TALK', $baseNs + 1 );
-define( 'WB_NS_PROPERTY', $baseNs + 2 );
-define( 'WB_NS_PROPERTY_TALK', $baseNs + 3 );
+       $baseNs = 120;
 
-// Register extra namespaces.
-$wgExtraNamespaces[WB_NS_ITEM] = 'Item';
-$wgExtraNamespaces[WB_NS_ITEM_TALK] = 'Item_talk';
-$wgExtraNamespaces[WB_NS_PROPERTY] = 'Property';
-$wgExtraNamespaces[WB_NS_PROPERTY_TALK] = 'Property_talk';
+       // Define custom namespaces. Use these exact constant names.
+       define( 'WB_NS_ITEM', $baseNs );
+       define( 'WB_NS_ITEM_TALK', $baseNs + 1 );
+       define( 'WB_NS_PROPERTY', $baseNs + 2 );
+       define( 'WB_NS_PROPERTY_TALK', $baseNs + 3 );
 
-// Tell Wikibase which namespace to use for which kind of entity
-$wgWBRepoSettings['entityNamespaces'][CONTENT_MODEL_WIKIBASE_ITEM] = 
WB_NS_ITEM;
-$wgWBRepoSettings['entityNamespaces'][CONTENT_MODEL_WIKIBASE_PROPERTY] = 
WB_NS_PROPERTY;
+       // Register extra namespaces.
+       $wgExtraNamespaces[WB_NS_ITEM] = 'Item';
+       $wgExtraNamespaces[WB_NS_ITEM_TALK] = 'Item_talk';
+       $wgExtraNamespaces[WB_NS_PROPERTY] = 'Property';
+       $wgExtraNamespaces[WB_NS_PROPERTY_TALK] = 'Property_talk';
 
-// NOTE: no need to set up $wgNamespaceContentModels, Wikibase will do that 
automatically based on $wgWBRepoSettings
+       // Tell Wikibase which namespace to use for which kind of entity
+       $wgWBRepoSettings['entityNamespaces'][CONTENT_MODEL_WIKIBASE_ITEM] = 
WB_NS_ITEM;
+       $wgWBRepoSettings['entityNamespaces'][CONTENT_MODEL_WIKIBASE_PROPERTY] 
= WB_NS_PROPERTY;
 
-// Tell MediaWIki to search the item namespace
-$wgNamespacesToBeSearchedDefault[WB_NS_ITEM] = true;
+       // NOTE: no need to set up $wgNamespaceContentModels, Wikibase will do 
that automatically based on $wgWBRepoSettings
 
-// More things to play with
-$wgWBRepoSettings['apiInDebug'] = false;
-$wgWBRepoSettings['apiInTest'] = false;
-$wgWBRepoSettings['apiWithRights'] = true;
-$wgWBRepoSettings['apiWithTokens'] = true;
+       // Tell MediaWIki to search the item namespace
+       $wgNamespacesToBeSearchedDefault[WB_NS_ITEM] = true;
 
-$wgGroupPermissions['wbeditor']['item-set'] = true;
+       // More things to play with
+       $wgWBRepoSettings['apiInDebug'] = false;
+       $wgWBRepoSettings['apiInTest'] = false;
+       $wgWBRepoSettings['apiWithRights'] = true;
+       $wgWBRepoSettings['apiWithTokens'] = true;
 
-$wgWBRepoSettings['normalizeItemByTitlePageNames'] = true;
+       $wgGroupPermissions['wbeditor']['item-set'] = true;
+
+       $wgWBRepoSettings['normalizeItemByTitlePageNames'] = true;
+} );
 
 
 /*
diff --git a/repo/config/Wikibase.experimental.php 
b/repo/config/Wikibase.experimental.php
index c8f8931..05aec07 100644
--- a/repo/config/Wikibase.experimental.php
+++ b/repo/config/Wikibase.experimental.php
@@ -33,36 +33,37 @@
        die( 'Not an entry point.' );
 }
 
-global $wgAPIModules, $wgHooks;
+call_user_func( function() {
+       global $wgAutoloadClasses, $wgAPIModules, $wgHooks;
 
-$dir = __DIR__ . '/../';
+       $dir = __DIR__ . '/../';
 
-$wgAutoloadClasses['Wikibase\Api\SetStatementRank']            = $dir . 
'includes/api/SetStatementRank.php';
+       $wgAutoloadClasses['Wikibase\Api\SetStatementRank']             = $dir 
. 'includes/api/SetStatementRank.php';
 
-unset( $dir );
+       $wgAPIModules['wbsetstatementrank']                             = 
'Wikibase\Api\SetStatementRank';
 
-$wgAPIModules['wbsetstatementrank']                            = 
'Wikibase\Api\SetStatementRank';
+       /**
+        * Hook to add PHPUnit test cases.
+        * @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList
+        *
+        * @since 0.3
+        *
+        * @param array &$files
+        *
+        * @return boolean
+        */
+       $wgHooks['UnitTestsList'][] = function( array &$files ) {
+               // @codeCoverageIgnoreStart
+               $testFiles = array(
+                       'api/SetStatementRank',
+               );
 
-/**
- * Hook to add PHPUnit test cases.
- * @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList
- *
- * @since 0.3
- *
- * @param array &$files
- *
- * @return boolean
- */
-$wgHooks['UnitTestsList'][] = function( array &$files ) {
-       // @codeCoverageIgnoreStart
-       $testFiles = array(
-               'api/SetStatementRank',
-       );
+               foreach ( $testFiles as $file ) {
+                       $files[] = __DIR__ . '/../tests/phpunit/includes/' . 
$file . 'Test.php';
+               }
 
-       foreach ( $testFiles as $file ) {
-               $files[] = __DIR__ . '/../tests/phpunit/includes/' . $file . 
'Test.php';
-       }
+               return true;
+               // @codeCoverageIgnoreEnd
+       };
 
-       return true;
-       // @codeCoverageIgnoreEnd
-};
+} );

-- 
To view, visit https://gerrit.wikimedia.org/r/72938
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I54ffac4ed8d8be7e140f23ee52289e28a96677b0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to