Remove extension function, move code into hooks
So the code only runs on requests which actually need it. Change-Id: I057f6e93b60037da2b01b1775f841726d14017ba
This commit is contained in:
@@ -76,6 +76,8 @@ class UniversalLanguageSelectorHooks {
|
||||
|
||||
if ( is_string( $wgULSGeoService ) ) {
|
||||
$out->addModules( 'ext.uls.geoclient' );
|
||||
} elseif ( $wgULSGeoService === true ) {
|
||||
$out->addScript( '<script src="//bits.wikimedia.org/geoiplookup"></script>' );
|
||||
}
|
||||
|
||||
if ( self::isToolbarEnabled( $out->getUser() ) ) {
|
||||
@@ -92,6 +94,35 @@ class UniversalLanguageSelectorHooks {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register conditional modules
|
||||
*
|
||||
* @param ResourceLoader $rl
|
||||
*/
|
||||
public static function onResourceLoaderRegisterModules( ResourceLoader &$rl ) {
|
||||
global $wgULSEventLogging;
|
||||
// If EventLogging integration is enabled, first ensure that
|
||||
// the EventLogging extension is present, then declare schema module.
|
||||
// If it is not present, emit a warning and disable logging.
|
||||
if ( $wgULSEventLogging ) {
|
||||
if ( class_exists( 'ResourceLoaderSchemaModule' ) ) {
|
||||
// NB: When updating the schema, remember also to update the version
|
||||
// in the schema default in the JavaScript library.
|
||||
/// @see https://meta.wikimedia.org/wiki/Schema:UniversalLanguageSelector
|
||||
$rl->register( 'schema.UniversalLanguageSelector', array(
|
||||
'class' => 'ResourceLoaderSchemaModule',
|
||||
'schema' => 'UniversalLanguageSelector',
|
||||
'revision' => 7327441,
|
||||
) );
|
||||
} else {
|
||||
wfWarn( 'UniversalLanguageSelector is configured to use EventLogging, '
|
||||
. 'but the extension is not available. Disabling wgULSEventLogging.' );
|
||||
$wgULSEventLogging = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $testModules array of javascript testing modules. 'qunit' is fed
|
||||
* using tests/qunit/QUnitTestResources.php.
|
||||
|
||||
Reference in New Issue
Block a user