jenkins-bot has submitted this change and it was merged. 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 1 file changed, 106 insertions(+), 99 deletions(-) Approvals: Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified 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' ); + } +} ); -- To view, visit https://gerrit.wikimedia.org/r/69091 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0722413d09a48e4d54680ea5888e419fc7e9075e Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits