Jeroen De Dauw has uploaded a new change for review. https://gerrit.wikimedia.org/r/69091
Change subject: Remove global scope assumptions in client and exec code in non global scope ...................................................................... Remove global scope assumptions in client and exec code in non global scope Change-Id: I0722413d09a48e4d54680ea5888e419fc7e9075e --- M client/WikibaseClient.php M repo/Wikibase.php M repo/config/Wikibase.experimental.php 3 files changed, 243 insertions(+), 228 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/91/69091/1 diff --git a/client/WikibaseClient.php b/client/WikibaseClient.php index 2d54e64..cff3235 100644 --- a/client/WikibaseClient.php +++ b/client/WikibaseClient.php @@ -28,10 +28,7 @@ return; } -define( 'WBC_VERSION', '0.4 alpha' - . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? '/experimental' : '' ) ); - -if ( version_compare( $wgVersion, '1.21c', '<' ) ) { // Needs to be 1.21c because version_compare() works in confusing ways. +if ( version_compare( $GLOBALS['wgVersion'], '1.21c', '<' ) ) { // Needs to be 1.21c because version_compare() works in confusing ways. die( "<b>Error:</b> Wikibase requires MediaWiki 1.21 alpha or above.\n" ); } @@ -41,122 +38,132 @@ } if ( !defined( 'WBL_VERSION' ) ) { - die( '<b>Error:</b> WikibaseClient depends on the <a href="https://www.mediawiki.org/wiki/Extension:WikibaseLib">WikibaseLib</a> extension.' ); + throw new Exception( 'WikibaseClient depends on the WikibaseLib extension.' ); } -$wgExtensionCredits['wikibase'][] = array( - 'path' => __DIR__, - 'name' => 'Wikibase Client', - 'version' => WBC_VERSION, - 'author' => array( - 'The Wikidata team', // TODO: link? - ), - 'url' => 'https://www.mediawiki.org/wiki/Extension:Wikibase_Client', - 'descriptionmsg' => 'wikibase-client-desc' -); +define( 'WBC_VERSION', '0.4 alpha' + . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? '/experimental' : '' ) ); -$dir = __DIR__ . '/'; +call_user_func( function() { + global $wgExtensionCredits, $wgExtensionMessagesFiles, $wgAutoloadClasses, $wgHooks; + global $wgAPIMetaModules, $wgSpecialPages, $wgSpecialPageGroups, $wgResourceModules; + global $wgWBClientStores, $wgWBClientSettings, $wgWBSettings; -// i18n -$wgExtensionMessagesFiles['wikibaseclient'] = $dir . 'WikibaseClient.i18n.php'; -$wgExtensionMessagesFiles['Wikibaseclientalias'] = $dir . 'WikibaseClient.i18n.alias.php'; -$wgExtensionMessagesFiles['wikibaseclientmagic'] = $dir . 'WikibaseClient.i18n.magic.php'; -// Autoloading -$wgAutoloadClasses['Wikibase\ClientHooks'] = $dir . 'WikibaseClient.hooks.php'; + $wgExtensionCredits['wikibase'][] = array( + 'path' => __DIR__, + 'name' => 'Wikibase Client', + 'version' => WBC_VERSION, + 'author' => array( + 'The Wikidata team', // TODO: link? + ), + 'url' => 'https://www.mediawiki.org/wiki/Extension:Wikibase_Client', + 'descriptionmsg' => 'wikibase-client-desc' + ); -$wgAutoloadClasses['Wikibase\CachedEntity'] = $dir . 'includes/CachedEntity.php'; -$wgAutoloadClasses['Wikibase\EntityCacheUpdater'] = $dir . 'includes/EntityCacheUpdater.php'; -$wgAutoloadClasses['Wikibase\EntityIdPropertyUpdater'] = $dir . 'includes/EntityIdPropertyUpdater.php'; -$wgAutoloadClasses['Wikibase\InterwikiSorter'] = $dir . 'includes/InterwikiSorter.php'; -$wgAutoloadClasses['Wikibase\LangLinkHandler'] = $dir . 'includes/LangLinkHandler.php'; -$wgAutoloadClasses['Wikibase\ChangeHandler'] = $dir . 'includes/ChangeHandler.php'; -$wgAutoloadClasses['Wikibase\NamespaceChecker'] = $dir . 'includes/NamespaceChecker.php'; -$wgAutoloadClasses['Wikibase\RepoItemLinkGenerator'] = $dir . 'includes/RepoItemLinkGenerator.php'; -$wgAutoloadClasses['Wikibase\RepoLinker'] = $dir . 'includes/RepoLinker.php'; -$wgAutoloadClasses['Wikibase\Client\WikibaseClient'] = $dir . 'includes/WikibaseClient.php'; -$wgAutoloadClasses['Scribunto_LuaWikibaseLibrary'] = $dir . 'includes/WikibaseLibrary.php'; -$wgAutoloadClasses['Wikibase\PageUpdater'] = $dir . 'includes/PageUpdater.php'; -$wgAutoloadClasses['Wikibase\WikiPageUpdater'] = $dir . 'includes/WikiPageUpdater.php'; + $dir = __DIR__ . '/'; -// includes/api -$wgAutoloadClasses['Wikibase\ApiClientInfo'] = $dir . 'includes/api/ApiClientInfo.php'; + // i18n + $wgExtensionMessagesFiles['wikibaseclient'] = $dir . 'WikibaseClient.i18n.php'; + $wgExtensionMessagesFiles['Wikibaseclientalias'] = $dir . 'WikibaseClient.i18n.alias.php'; + $wgExtensionMessagesFiles['wikibaseclientmagic'] = $dir . 'WikibaseClient.i18n.magic.php'; -// includes/modules -$wgAutoloadClasses['Wikibase\SiteModule'] = $dir . 'includes/modules/SiteModule.php'; + // Autoloading + $wgAutoloadClasses['Wikibase\ClientHooks'] = $dir . 'WikibaseClient.hooks.php'; -// include/parserhooks -$wgAutoloadClasses['Wikibase\NoLangLinkHandler'] = $dir . 'includes/parserhooks/NoLangLinkHandler.php'; -$wgAutoloadClasses['Wikibase\ParserErrorMessageFormatter'] = $dir . 'includes/parserhooks/ParserErrorMessageFormatter.php'; -$wgAutoloadClasses['Wikibase\PropertyParserFunction'] = $dir . 'includes/parserhooks/PropertyParserFunction.php'; + $wgAutoloadClasses['Wikibase\CachedEntity'] = $dir . 'includes/CachedEntity.php'; + $wgAutoloadClasses['Wikibase\EntityCacheUpdater'] = $dir . 'includes/EntityCacheUpdater.php'; + $wgAutoloadClasses['Wikibase\EntityIdPropertyUpdater'] = $dir . 'includes/EntityIdPropertyUpdater.php'; + $wgAutoloadClasses['Wikibase\InterwikiSorter'] = $dir . 'includes/InterwikiSorter.php'; + $wgAutoloadClasses['Wikibase\LangLinkHandler'] = $dir . 'includes/LangLinkHandler.php'; + $wgAutoloadClasses['Wikibase\ChangeHandler'] = $dir . 'includes/ChangeHandler.php'; + $wgAutoloadClasses['Wikibase\NamespaceChecker'] = $dir . 'includes/NamespaceChecker.php'; + $wgAutoloadClasses['Wikibase\RepoItemLinkGenerator'] = $dir . 'includes/RepoItemLinkGenerator.php'; + $wgAutoloadClasses['Wikibase\RepoLinker'] = $dir . 'includes/RepoLinker.php'; + $wgAutoloadClasses['Wikibase\Client\WikibaseClient'] = $dir . 'includes/WikibaseClient.php'; + $wgAutoloadClasses['Scribunto_LuaWikibaseLibrary'] = $dir . 'includes/WikibaseLibrary.php'; + $wgAutoloadClasses['Wikibase\PageUpdater'] = $dir . 'includes/PageUpdater.php'; + $wgAutoloadClasses['Wikibase\WikiPageUpdater'] = $dir . 'includes/WikiPageUpdater.php'; -// includes/recentchanges -$wgAutoloadClasses['Wikibase\ExternalChangesLine'] = $dir . 'includes/recentchanges/ExternalChangesLine.php'; -$wgAutoloadClasses['Wikibase\ExternalRecentChange'] = $dir . 'includes/recentchanges/ExternalRecentChange.php'; -$wgAutoloadClasses['Wikibase\RecentChangesFilterOptions'] = $dir . 'includes/recentchanges/RecentChangesFilterOptions.php'; + // includes/api + $wgAutoloadClasses['Wikibase\ApiClientInfo'] = $dir . 'includes/api/ApiClientInfo.php'; -// includes/specials -$wgAutoloadClasses['SpecialUnconnectedPages'] = $dir . 'includes/specials/SpecialUnconnectedPages.php'; + // includes/modules + $wgAutoloadClasses['Wikibase\SiteModule'] = $dir . 'includes/modules/SiteModule.php'; -// includes/store -$wgAutoloadClasses['Wikibase\ClientStore'] = $dir . 'includes/store/ClientStore.php'; -$wgAutoloadClasses['Wikibase\EntityCache'] = $dir . 'includes/store/EntityCache.php'; + // include/parserhooks + $wgAutoloadClasses['Wikibase\NoLangLinkHandler'] = $dir . 'includes/parserhooks/NoLangLinkHandler.php'; + $wgAutoloadClasses['Wikibase\ParserErrorMessageFormatter'] = $dir . 'includes/parserhooks/ParserErrorMessageFormatter.php'; + $wgAutoloadClasses['Wikibase\PropertyParserFunction'] = $dir . 'includes/parserhooks/PropertyParserFunction.php'; -// includes/store/sql -$wgAutoloadClasses['Wikibase\CachingSqlStore'] = $dir . 'includes/store/sql/CachingSqlStore.php'; -$wgAutoloadClasses['Wikibase\DirectSqlStore'] = $dir . 'includes/store/sql/DirectSqlStore.php'; -$wgAutoloadClasses['Wikibase\EntityCacheTable'] = $dir . 'includes/store/sql/EntityCacheTable.php'; + // includes/recentchanges + $wgAutoloadClasses['Wikibase\ExternalChangesLine'] = $dir . 'includes/recentchanges/ExternalChangesLine.php'; + $wgAutoloadClasses['Wikibase\ExternalRecentChange'] = $dir . 'includes/recentchanges/ExternalRecentChange.php'; + $wgAutoloadClasses['Wikibase\RecentChangesFilterOptions'] = $dir . 'includes/recentchanges/RecentChangesFilterOptions.php'; -// test -$wgAutoloadClasses['Wikibase\Test\MockPageUpdater'] = $dir . 'tests/phpunit/MockPageUpdater.php'; + // includes/specials + $wgAutoloadClasses['SpecialUnconnectedPages'] = $dir . 'includes/specials/SpecialUnconnectedPages.php'; -// Hooks -$wgHooks['UnitTestsList'][] = '\Wikibase\ClientHooks::registerUnitTests'; -$wgHooks['LoadExtensionSchemaUpdates'][] = '\Wikibase\ClientHooks::onSchemaUpdate'; -$wgHooks['OldChangesListRecentChangesLine'][] = '\Wikibase\ClientHooks::onOldChangesListRecentChangesLine'; -$wgHooks['OutputPageParserOutput'][] = '\Wikibase\ClientHooks::onOutputPageParserOutput'; -$wgHooks['ParserAfterParse'][] = '\Wikibase\ClientHooks::onParserAfterParse'; -$wgHooks['ParserFirstCallInit'][] = '\Wikibase\ClientHooks::onParserFirstCallInit'; -$wgHooks['MagicWordwgVariableIDs'][] = '\Wikibase\ClientHooks::onMagicWordwgVariableIDs'; -$wgHooks['ParserGetVariableValueSwitch'][] = '\Wikibase\ClientHooks::onParserGetVariableValueSwitch'; -$wgHooks['SkinTemplateOutputPageBeforeExec'][] = '\Wikibase\ClientHooks::onSkinTemplateOutputPageBeforeExec'; -$wgHooks['SpecialMovepageAfterMove'][] = '\Wikibase\ClientHooks::onSpecialMovepageAfterMove'; -$wgHooks['SpecialWatchlistQuery'][] = '\Wikibase\ClientHooks::onSpecialWatchlistQuery'; -$wgHooks['SpecialRecentChangesQuery'][] = '\Wikibase\ClientHooks::onSpecialRecentChangesQuery'; -$wgHooks['SpecialRecentChangesFilters'][] = '\Wikibase\ClientHooks::onSpecialRecentChangesFilters'; -$wgHooks['GetPreferences'][] = '\Wikibase\ClientHooks::onGetPreferences'; -$wgHooks['BeforePageDisplay'][] = '\Wikibase\ClientHooks::onBeforePageDisplay'; -$wgHooks['ScribuntoExternalLibraries'][] = '\Wikibase\ClientHooks::onScribuntoExternalLibraries'; -$wgHooks['SpecialWatchlistFilters'][] = '\Wikibase\ClientHooks::onSpecialWatchlistFilters'; + // includes/store + $wgAutoloadClasses['Wikibase\ClientStore'] = $dir . 'includes/store/ClientStore.php'; + $wgAutoloadClasses['Wikibase\EntityCache'] = $dir . 'includes/store/EntityCache.php'; -// extension hooks -$wgHooks['WikibaseDeleteData'][] = '\Wikibase\ClientHooks::onWikibaseDeleteData'; -$wgHooks['WikibaseRebuildData'][] = '\Wikibase\ClientHooks::onWikibaseRebuildData'; -$wgHooks['InfoAction'][] = '\Wikibase\ClientHooks::onInfoAction'; + // includes/store/sql + $wgAutoloadClasses['Wikibase\CachingSqlStore'] = $dir . 'includes/store/sql/CachingSqlStore.php'; + $wgAutoloadClasses['Wikibase\DirectSqlStore'] = $dir . 'includes/store/sql/DirectSqlStore.php'; + $wgAutoloadClasses['Wikibase\EntityCacheTable'] = $dir . 'includes/store/sql/EntityCacheTable.php'; -// api modules -$wgAPIMetaModules['wikibase'] = 'Wikibase\ApiClientInfo'; + // test + $wgAutoloadClasses['Wikibase\Test\MockPageUpdater'] = $dir . 'tests/phpunit/MockPageUpdater.php'; -// Special page registration -$wgSpecialPages['UnconnectedPages'] = 'SpecialUnconnectedPages'; + // Hooks + $wgHooks['UnitTestsList'][] = '\Wikibase\ClientHooks::registerUnitTests'; + $wgHooks['LoadExtensionSchemaUpdates'][] = '\Wikibase\ClientHooks::onSchemaUpdate'; + $wgHooks['OldChangesListRecentChangesLine'][] = '\Wikibase\ClientHooks::onOldChangesListRecentChangesLine'; + $wgHooks['OutputPageParserOutput'][] = '\Wikibase\ClientHooks::onOutputPageParserOutput'; + $wgHooks['ParserAfterParse'][] = '\Wikibase\ClientHooks::onParserAfterParse'; + $wgHooks['ParserFirstCallInit'][] = '\Wikibase\ClientHooks::onParserFirstCallInit'; + $wgHooks['MagicWordwgVariableIDs'][] = '\Wikibase\ClientHooks::onMagicWordwgVariableIDs'; + $wgHooks['ParserGetVariableValueSwitch'][] = '\Wikibase\ClientHooks::onParserGetVariableValueSwitch'; + $wgHooks['SkinTemplateOutputPageBeforeExec'][] = '\Wikibase\ClientHooks::onSkinTemplateOutputPageBeforeExec'; + $wgHooks['SpecialMovepageAfterMove'][] = '\Wikibase\ClientHooks::onSpecialMovepageAfterMove'; + $wgHooks['SpecialWatchlistQuery'][] = '\Wikibase\ClientHooks::onSpecialWatchlistQuery'; + $wgHooks['SpecialRecentChangesQuery'][] = '\Wikibase\ClientHooks::onSpecialRecentChangesQuery'; + $wgHooks['SpecialRecentChangesFilters'][] = '\Wikibase\ClientHooks::onSpecialRecentChangesFilters'; + $wgHooks['GetPreferences'][] = '\Wikibase\ClientHooks::onGetPreferences'; + $wgHooks['BeforePageDisplay'][] = '\Wikibase\ClientHooks::onBeforePageDisplay'; + $wgHooks['ScribuntoExternalLibraries'][] = '\Wikibase\ClientHooks::onScribuntoExternalLibraries'; + $wgHooks['SpecialWatchlistFilters'][] = '\Wikibase\ClientHooks::onSpecialWatchlistFilters'; -// Special page groups -$wgSpecialPageGroups['UnconnectedPages'] = 'wikibaseclient'; + // extension hooks + $wgHooks['WikibaseDeleteData'][] = '\Wikibase\ClientHooks::onWikibaseDeleteData'; + $wgHooks['WikibaseRebuildData'][] = '\Wikibase\ClientHooks::onWikibaseRebuildData'; + $wgHooks['InfoAction'][] = '\Wikibase\ClientHooks::onInfoAction'; -// Resource loader modules -$wgResourceModules = array_merge( $wgResourceModules, include( "$dir/resources/Resources.php" ) ); + // api modules + $wgAPIMetaModules['wikibase'] = 'Wikibase\ApiClientInfo'; -$wgWBClientStores = array(); -$wgWBClientStores['CachingSqlStore'] = 'Wikibase\CachingSqlStore'; -$wgWBClientStores['DirectSqlStore'] = 'Wikibase\DirectSqlStore'; + // Special page registration + $wgSpecialPages['UnconnectedPages'] = 'SpecialUnconnectedPages'; -$wgWBClientSettings = array_merge( - require( __DIR__ . '/../lib/config/WikibaseLib.default.php' ), - require( __DIR__ . '/config/WikibaseClient.default.php' ) -); + // Special page groups + $wgSpecialPageGroups['UnconnectedPages'] = 'wikibaseclient'; -$wgWBSettings = &$wgWBClientSettings; // B/C + // Resource loader modules + $wgResourceModules = array_merge( $wgResourceModules, include( "$dir/resources/Resources.php" ) ); -if ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ) { - include_once( $dir . 'config/WikibaseClient.experimental.php' ); -} + $wgWBClientStores = array(); + $wgWBClientStores['CachingSqlStore'] = 'Wikibase\CachingSqlStore'; + $wgWBClientStores['DirectSqlStore'] = 'Wikibase\DirectSqlStore'; + + $wgWBClientSettings = array_merge( + require( __DIR__ . '/../lib/config/WikibaseLib.default.php' ), + require( __DIR__ . '/config/WikibaseClient.default.php' ) + ); + + $wgWBSettings = &$wgWBClientSettings; // B/C + + if ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ) { + include_once( $dir . 'config/WikibaseClient.experimental.php' ); + } +} ); diff --git a/repo/Wikibase.php b/repo/Wikibase.php index ea6c1ed..d52d48a 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -39,10 +39,7 @@ return; } -define( 'WB_VERSION', '0.4 alpha' - . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? '/experimental' : '' ) ); - -if ( version_compare( $wgVersion, '1.20c', '<' ) ) { // Needs to be 1.20c because version_compare() works in confusing ways. +if ( version_compare( $GLOBALS['wgVersion'], '1.20c', '<' ) ) { // Needs to be 1.20c because version_compare() works in confusing ways. die( '<b>Error:</b> Wikibase requires MediaWiki 1.20 or above.' ); } @@ -52,145 +49,154 @@ } if ( !defined( 'WBL_VERSION' ) ) { - die( '<b>Error:</b> Wikibase depends on the <a href="https://www.mediawiki.org/wiki/Extension:WikibaseLib">WikibaseLib</a> extension.' ); + throw new Exception( 'Wikibase depends on the WikibaseLib extension.' ); } -$wgExtensionCredits['wikibase'][] = array( - 'path' => __DIR__, - 'name' => 'Wikibase Repository', - 'version' => WB_VERSION, - 'author' => array( - 'The Wikidata team', // TODO: link? - ), - 'url' => 'https://www.mediawiki.org/wiki/Extension:Wikibase', - 'descriptionmsg' => 'wikibase-desc' -); +define( 'WB_VERSION', '0.4 alpha' + . ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ? '/experimental' : '' ) ); -// constants -define( 'CONTENT_MODEL_WIKIBASE_ITEM', "wikibase-item" ); -define( 'CONTENT_MODEL_WIKIBASE_PROPERTY', "wikibase-property" ); +call_user_func( function() { + global $wgExtensionCredits, $wgAutoloadClasses, $wgGroupPermissions, $wgExtensionMessagesFiles; + global $wgAPIModules, $wgSpecialPages, $wgSpecialPageGroups, $wgHooks, $wgContentHandlers; + global $wgWBStores, $wgWBRepoSettings, $wgWBSettings, $wgResourceModules; -// Autoloading -foreach ( include( __DIR__ . '/Wikibase.classes.php' ) as $class => $file ) { - $wgAutoloadClasses[$class] = __DIR__ . '/' . $file; -} + $wgExtensionCredits['wikibase'][] = array( + 'path' => __DIR__, + 'name' => 'Wikibase Repository', + 'version' => WB_VERSION, + 'author' => array( + 'The Wikidata team', + ), + 'url' => 'https://www.mediawiki.org/wiki/Extension:Wikibase', + 'descriptionmsg' => 'wikibase-desc' + ); -// rights -// names should be according to other naming scheme -$wgGroupPermissions['*']['item-override'] = true; -$wgGroupPermissions['*']['item-create'] = true; -$wgGroupPermissions['*']['item-remove'] = true; -$wgGroupPermissions['*']['property-override'] = true; -$wgGroupPermissions['*']['property-create'] = true; -$wgGroupPermissions['*']['property-remove'] = true; -$wgGroupPermissions['*']['alias-update'] = true; -$wgGroupPermissions['*']['alias-remove'] = true; -$wgGroupPermissions['*']['sitelink-remove'] = true; -$wgGroupPermissions['*']['sitelink-update'] = true; -$wgGroupPermissions['*']['linktitles-update'] = true; -$wgGroupPermissions['*']['label-remove'] = true; -$wgGroupPermissions['*']['label-update'] = true; -$wgGroupPermissions['*']['description-remove'] = true; -$wgGroupPermissions['*']['description-update'] = true; + // constants + define( 'CONTENT_MODEL_WIKIBASE_ITEM', "wikibase-item" ); + define( 'CONTENT_MODEL_WIKIBASE_PROPERTY', "wikibase-property" ); -// i18n -$wgExtensionMessagesFiles['Wikibase'] = __DIR__ . '/Wikibase.i18n.php'; -$wgExtensionMessagesFiles['WikibaseAlias'] = __DIR__ . '/Wikibase.i18n.alias.php'; -$wgExtensionMessagesFiles['WikibaseNS'] = __DIR__ . '/Wikibase.i18n.namespaces.php'; + // Autoloading + foreach ( include( __DIR__ . '/Wikibase.classes.php' ) as $class => $file ) { + $wgAutoloadClasses[$class] = __DIR__ . '/' . $file; + } -// API module registration -$wgAPIModules['wbgetentities'] = 'Wikibase\Api\GetEntities'; -$wgAPIModules['wbsetlabel'] = 'Wikibase\Api\SetLabel'; -$wgAPIModules['wbsetdescription'] = 'Wikibase\Api\SetDescription'; -$wgAPIModules['wbsearchentities'] = 'Wikibase\Api\SearchEntities'; -$wgAPIModules['wbsetaliases'] = 'Wikibase\Api\SetAliases'; -$wgAPIModules['wbeditentity'] = 'Wikibase\Api\EditEntity'; -$wgAPIModules['wblinktitles'] = 'Wikibase\Api\LinkTitles'; -$wgAPIModules['wbsetsitelink'] = 'Wikibase\Api\SetSiteLink'; -$wgAPIModules['wbcreateclaim'] = 'Wikibase\Api\CreateClaim'; -$wgAPIModules['wbgetclaims'] = 'Wikibase\Api\GetClaims'; -$wgAPIModules['wbremoveclaims'] = 'Wikibase\Api\RemoveClaims'; -$wgAPIModules['wbsetclaimvalue'] = 'Wikibase\Api\SetClaimValue'; -$wgAPIModules['wbsetreference'] = 'Wikibase\Api\SetReference'; -$wgAPIModules['wbremovereferences'] = 'Wikibase\Api\RemoveReferences'; -$wgAPIModules['wbsetclaim'] = 'Wikibase\Api\SetClaim'; -$wgAPIModules['wbremovequalifiers'] = 'Wikibase\Api\RemoveQualifiers'; -$wgAPIModules['wbsetqualifier'] = 'Wikibase\Api\SetQualifier'; + // rights + // names should be according to other naming scheme + $wgGroupPermissions['*']['item-override'] = true; + $wgGroupPermissions['*']['item-create'] = true; + $wgGroupPermissions['*']['item-remove'] = true; + $wgGroupPermissions['*']['property-override'] = true; + $wgGroupPermissions['*']['property-create'] = true; + $wgGroupPermissions['*']['property-remove'] = true; + $wgGroupPermissions['*']['alias-update'] = true; + $wgGroupPermissions['*']['alias-remove'] = true; + $wgGroupPermissions['*']['sitelink-remove'] = true; + $wgGroupPermissions['*']['sitelink-update'] = true; + $wgGroupPermissions['*']['linktitles-update'] = true; + $wgGroupPermissions['*']['label-remove'] = true; + $wgGroupPermissions['*']['label-update'] = true; + $wgGroupPermissions['*']['description-remove'] = true; + $wgGroupPermissions['*']['description-update'] = true; -// Special page registration -$wgSpecialPages['NewItem'] = 'SpecialNewItem'; -$wgSpecialPages['NewProperty'] = 'SpecialNewProperty'; -$wgSpecialPages['ItemByTitle'] = 'SpecialItemByTitle'; -$wgSpecialPages['ItemDisambiguation'] = 'SpecialItemDisambiguation'; -$wgSpecialPages['ItemsWithoutSitelinks'] = 'SpecialItemsWithoutSitelinks'; -$wgSpecialPages['SetLabel'] = 'SpecialSetLabel'; -$wgSpecialPages['SetDescription'] = 'SpecialSetDescription'; -$wgSpecialPages['SetAliases'] = 'SpecialSetAliases'; -$wgSpecialPages['SetSiteLink'] = 'SpecialSetSiteLink'; -$wgSpecialPages['EntitiesWithoutLabel'] = 'SpecialEntitiesWithoutLabel'; -$wgSpecialPages['NewProperty'] = 'SpecialNewProperty'; -$wgSpecialPages['ListDatatypes'] = 'SpecialListDatatypes'; -$wgSpecialPages['DispatchStats'] = 'SpecialDispatchStats'; -$wgSpecialPages['EntityData'] = 'SpecialEntityData'; + // i18n + $wgExtensionMessagesFiles['Wikibase'] = __DIR__ . '/Wikibase.i18n.php'; + $wgExtensionMessagesFiles['WikibaseAlias'] = __DIR__ . '/Wikibase.i18n.alias.php'; + $wgExtensionMessagesFiles['WikibaseNS'] = __DIR__ . '/Wikibase.i18n.namespaces.php'; -// Special page groups -$wgSpecialPageGroups['NewItem'] = 'wikibaserepo'; -$wgSpecialPageGroups['NewProperty'] = 'wikibaserepo'; -$wgSpecialPageGroups['ItemByTitle'] = 'wikibaserepo'; -$wgSpecialPageGroups['ItemDisambiguation'] = 'wikibaserepo'; -$wgSpecialPageGroups['ItemsWithoutSitelinks'] = 'wikibaserepo'; -$wgSpecialPageGroups['SetLabel'] = 'wikibaserepo'; -$wgSpecialPageGroups['SetDescription'] = 'wikibaserepo'; -$wgSpecialPageGroups['SetAliases'] = 'wikibaserepo'; -$wgSpecialPageGroups['SetSiteLink'] = 'wikibaserepo'; -$wgSpecialPageGroups['EntitiesWithoutLabel'] = 'wikibaserepo'; -$wgSpecialPageGroups['EntityData'] = 'wikibaserepo'; -$wgSpecialPageGroups['ListDatatypes'] = 'wikibaserepo'; -$wgSpecialPageGroups['DispatchStats'] = 'wikibaserepo'; + // API module registration + $wgAPIModules['wbgetentities'] = 'Wikibase\Api\GetEntities'; + $wgAPIModules['wbsetlabel'] = 'Wikibase\Api\SetLabel'; + $wgAPIModules['wbsetdescription'] = 'Wikibase\Api\SetDescription'; + $wgAPIModules['wbsearchentities'] = 'Wikibase\Api\SearchEntities'; + $wgAPIModules['wbsetaliases'] = 'Wikibase\Api\SetAliases'; + $wgAPIModules['wbeditentity'] = 'Wikibase\Api\EditEntity'; + $wgAPIModules['wblinktitles'] = 'Wikibase\Api\LinkTitles'; + $wgAPIModules['wbsetsitelink'] = 'Wikibase\Api\SetSiteLink'; + $wgAPIModules['wbcreateclaim'] = 'Wikibase\Api\CreateClaim'; + $wgAPIModules['wbgetclaims'] = 'Wikibase\Api\GetClaims'; + $wgAPIModules['wbremoveclaims'] = 'Wikibase\Api\RemoveClaims'; + $wgAPIModules['wbsetclaimvalue'] = 'Wikibase\Api\SetClaimValue'; + $wgAPIModules['wbsetreference'] = 'Wikibase\Api\SetReference'; + $wgAPIModules['wbremovereferences'] = 'Wikibase\Api\RemoveReferences'; + $wgAPIModules['wbsetclaim'] = 'Wikibase\Api\SetClaim'; + $wgAPIModules['wbremovequalifiers'] = 'Wikibase\Api\RemoveQualifiers'; + $wgAPIModules['wbsetqualifier'] = 'Wikibase\Api\SetQualifier'; -// Hooks -$wgHooks['BeforePageDisplay'][] = 'Wikibase\RepoHooks::onBeforePageDisplay'; -$wgHooks['LoadExtensionSchemaUpdates'][] = 'Wikibase\RepoHooks::onSchemaUpdate'; -$wgHooks['UnitTestsList'][] = 'Wikibase\RepoHooks::registerUnitTests'; -$wgHooks['NamespaceIsMovable'][] = 'Wikibase\RepoHooks::onNamespaceIsMovable'; -$wgHooks['NewRevisionFromEditComplete'][] = 'Wikibase\RepoHooks::onNewRevisionFromEditComplete'; -$wgHooks['SkinTemplateNavigation'][] = 'Wikibase\RepoHooks::onPageTabs'; -$wgHooks['RecentChange_save'][] = 'Wikibase\RepoHooks::onRecentChangeSave'; -$wgHooks['ArticleDeleteComplete'][] = 'Wikibase\RepoHooks::onArticleDeleteComplete'; -$wgHooks['ArticleUndelete'][] = 'Wikibase\RepoHooks::onArticleUndelete'; -$wgHooks['LinkBegin'][] = 'Wikibase\RepoHooks::onLinkBegin'; -$wgHooks['OutputPageBodyAttributes'][] = 'Wikibase\RepoHooks::onOutputPageBodyAttributes'; -//FIXME: handle other types of entities with autocomments too! -$wgHooks['FormatAutocomments'][] = array( 'Wikibase\Autocomment::onFormat', array( CONTENT_MODEL_WIKIBASE_ITEM, "wikibase-item" ) ); -$wgHooks['FormatAutocomments'][] = array( 'Wikibase\Autocomment::onFormat', array( CONTENT_MODEL_WIKIBASE_PROPERTY, "wikibase-property" ) ); -$wgHooks['PageHistoryLineEnding'][] = 'Wikibase\RepoHooks::onPageHistoryLineEnding'; -$wgHooks['WikibaseRebuildData'][] = 'Wikibase\RepoHooks::onWikibaseRebuildData'; -$wgHooks['WikibaseDeleteData'][] = 'Wikibase\RepoHooks::onWikibaseDeleteData'; -$wgHooks['ApiCheckCanExecute'][] = 'Wikibase\RepoHooks::onApiCheckCanExecute'; -$wgHooks['SetupAfterCache'][] = 'Wikibase\RepoHooks::onSetupAfterCache'; -$wgHooks['ShowSearchHit'][] = 'Wikibase\RepoHooks::onShowSearchHit'; -$wgHooks['TitleGetRestrictionTypes'][] = 'Wikibase\RepoHooks::onTitleGetRestrictionTypes'; -$wgHooks['AbuseFilter-contentToString'][] = 'Wikibase\RepoHooks::onAbuseFilterContentToString'; -$wgHooks['SpecialPage_reorderPages'][] = 'Wikibase\RepoHooks::onSpecialPage_reorderPages'; + // Special page registration + $wgSpecialPages['NewItem'] = 'SpecialNewItem'; + $wgSpecialPages['NewProperty'] = 'SpecialNewProperty'; + $wgSpecialPages['ItemByTitle'] = 'SpecialItemByTitle'; + $wgSpecialPages['ItemDisambiguation'] = 'SpecialItemDisambiguation'; + $wgSpecialPages['ItemsWithoutSitelinks'] = 'SpecialItemsWithoutSitelinks'; + $wgSpecialPages['SetLabel'] = 'SpecialSetLabel'; + $wgSpecialPages['SetDescription'] = 'SpecialSetDescription'; + $wgSpecialPages['SetAliases'] = 'SpecialSetAliases'; + $wgSpecialPages['SetSiteLink'] = 'SpecialSetSiteLink'; + $wgSpecialPages['EntitiesWithoutLabel'] = 'SpecialEntitiesWithoutLabel'; + $wgSpecialPages['NewProperty'] = 'SpecialNewProperty'; + $wgSpecialPages['ListDatatypes'] = 'SpecialListDatatypes'; + $wgSpecialPages['DispatchStats'] = 'SpecialDispatchStats'; + $wgSpecialPages['EntityData'] = 'SpecialEntityData'; -// Resource Loader Modules: -$wgResourceModules = array_merge( $wgResourceModules, include( __DIR__ . "/resources/Resources.php" ) ); + // Special page groups + $wgSpecialPageGroups['NewItem'] = 'wikibaserepo'; + $wgSpecialPageGroups['NewProperty'] = 'wikibaserepo'; + $wgSpecialPageGroups['ItemByTitle'] = 'wikibaserepo'; + $wgSpecialPageGroups['ItemDisambiguation'] = 'wikibaserepo'; + $wgSpecialPageGroups['ItemsWithoutSitelinks'] = 'wikibaserepo'; + $wgSpecialPageGroups['SetLabel'] = 'wikibaserepo'; + $wgSpecialPageGroups['SetDescription'] = 'wikibaserepo'; + $wgSpecialPageGroups['SetAliases'] = 'wikibaserepo'; + $wgSpecialPageGroups['SetSiteLink'] = 'wikibaserepo'; + $wgSpecialPageGroups['EntitiesWithoutLabel'] = 'wikibaserepo'; + $wgSpecialPageGroups['EntityData'] = 'wikibaserepo'; + $wgSpecialPageGroups['ListDatatypes'] = 'wikibaserepo'; + $wgSpecialPageGroups['DispatchStats'] = 'wikibaserepo'; -// register hooks and handlers -$wgContentHandlers[CONTENT_MODEL_WIKIBASE_ITEM] = '\Wikibase\ItemHandler'; -$wgContentHandlers[CONTENT_MODEL_WIKIBASE_PROPERTY] = '\Wikibase\PropertyHandler'; + // Hooks + $wgHooks['BeforePageDisplay'][] = 'Wikibase\RepoHooks::onBeforePageDisplay'; + $wgHooks['LoadExtensionSchemaUpdates'][] = 'Wikibase\RepoHooks::onSchemaUpdate'; + $wgHooks['UnitTestsList'][] = 'Wikibase\RepoHooks::registerUnitTests'; + $wgHooks['NamespaceIsMovable'][] = 'Wikibase\RepoHooks::onNamespaceIsMovable'; + $wgHooks['NewRevisionFromEditComplete'][] = 'Wikibase\RepoHooks::onNewRevisionFromEditComplete'; + $wgHooks['SkinTemplateNavigation'][] = 'Wikibase\RepoHooks::onPageTabs'; + $wgHooks['RecentChange_save'][] = 'Wikibase\RepoHooks::onRecentChangeSave'; + $wgHooks['ArticleDeleteComplete'][] = 'Wikibase\RepoHooks::onArticleDeleteComplete'; + $wgHooks['ArticleUndelete'][] = 'Wikibase\RepoHooks::onArticleUndelete'; + $wgHooks['LinkBegin'][] = 'Wikibase\RepoHooks::onLinkBegin'; + $wgHooks['OutputPageBodyAttributes'][] = 'Wikibase\RepoHooks::onOutputPageBodyAttributes'; + //FIXME: handle other types of entities with autocomments too! + $wgHooks['FormatAutocomments'][] = array( 'Wikibase\Autocomment::onFormat', array( CONTENT_MODEL_WIKIBASE_ITEM, "wikibase-item" ) ); + $wgHooks['FormatAutocomments'][] = array( 'Wikibase\Autocomment::onFormat', array( CONTENT_MODEL_WIKIBASE_PROPERTY, "wikibase-property" ) ); + $wgHooks['PageHistoryLineEnding'][] = 'Wikibase\RepoHooks::onPageHistoryLineEnding'; + $wgHooks['WikibaseRebuildData'][] = 'Wikibase\RepoHooks::onWikibaseRebuildData'; + $wgHooks['WikibaseDeleteData'][] = 'Wikibase\RepoHooks::onWikibaseDeleteData'; + $wgHooks['ApiCheckCanExecute'][] = 'Wikibase\RepoHooks::onApiCheckCanExecute'; + $wgHooks['SetupAfterCache'][] = 'Wikibase\RepoHooks::onSetupAfterCache'; + $wgHooks['ShowSearchHit'][] = 'Wikibase\RepoHooks::onShowSearchHit'; + $wgHooks['TitleGetRestrictionTypes'][] = 'Wikibase\RepoHooks::onTitleGetRestrictionTypes'; + $wgHooks['AbuseFilter-contentToString'][] = 'Wikibase\RepoHooks::onAbuseFilterContentToString'; + $wgHooks['SpecialPage_reorderPages'][] = 'Wikibase\RepoHooks::onSpecialPage_reorderPages'; -$wgWBStores = array(); + // Resource Loader Modules: + $wgResourceModules = array_merge( $wgResourceModules, include( __DIR__ . "/resources/Resources.php" ) ); -$wgWBStores['sqlstore'] = 'Wikibase\SqlStore'; + // register hooks and handlers + $wgContentHandlers[CONTENT_MODEL_WIKIBASE_ITEM] = '\Wikibase\ItemHandler'; + $wgContentHandlers[CONTENT_MODEL_WIKIBASE_PROPERTY] = '\Wikibase\PropertyHandler'; -$wgWBRepoSettings = array_merge( - require( __DIR__ . '/../lib/config/WikibaseLib.default.php' ), - require( __DIR__ . '/config/Wikibase.default.php' ) -); + $wgWBStores = array(); -$wgWBSettings = &$wgWBRepoSettings; // B/C + $wgWBStores['sqlstore'] = 'Wikibase\SqlStore'; -if ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ) { - include_once( __DIR__ . '/config/Wikibase.experimental.php' ); -} + $wgWBRepoSettings = array_merge( + require( __DIR__ . '/../lib/config/WikibaseLib.default.php' ), + require( __DIR__ . '/config/Wikibase.default.php' ) + ); + + $wgWBSettings = &$wgWBRepoSettings; // B/C + + if ( defined( 'WB_EXPERIMENTAL_FEATURES' ) && WB_EXPERIMENTAL_FEATURES ) { + include_once( __DIR__ . '/config/Wikibase.experimental.php' ); + } +} ); diff --git a/repo/config/Wikibase.experimental.php b/repo/config/Wikibase.experimental.php index 094a6ee..c8f8931 100644 --- a/repo/config/Wikibase.experimental.php +++ b/repo/config/Wikibase.experimental.php @@ -33,6 +33,8 @@ die( 'Not an entry point.' ); } +global $wgAPIModules, $wgHooks; + $dir = __DIR__ . '/../'; $wgAutoloadClasses['Wikibase\Api\SetStatementRank'] = $dir . 'includes/api/SetStatementRank.php'; -- To view, visit https://gerrit.wikimedia.org/r/69091 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0722413d09a48e4d54680ea5888e419fc7e9075e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits