Hygiene: Rename SchemaPopupsSamplingRate

The SchemaPopupsSamplingRate config variable is inconsistently named and
even forwarded to the client as wgPopupsSchemaPopupsSamplingRate.

Changes:
* SchemaPopupsSamplingRate -> PopupsSchemaSamplingRate
* Forward PopupsSchemaSamplingRate to the client as
  $wgPopupsSchemaSamplingRate.

Bug: T146889
Bug: T146434
Change-Id: I80d6a0abccf462e2eb0fd96af6849b5e82b49c26
This commit is contained in:
Sam Smith 2017-01-15 10:50:04 -08:00
parent c13ab30bfa
commit 98b2dcf631
5 changed files with 9 additions and 9 deletions

View file

@ -141,7 +141,7 @@ class PopupsHooks {
*/
public static function onResourceLoaderGetConfigVars( array &$vars ) {
$conf = PopupsContext::getInstance()->getConfig();
$vars['wgPopupsSchemaPopupsSamplingRate'] = $conf->get( 'SchemaPopupsSamplingRate' );
$vars['wgPopupsSchemaSamplingRate'] = $conf->get( 'PopupsSchemaSamplingRate' );
}
/**

View file

@ -47,8 +47,8 @@
"config": {
"@PopupsBetaFeature": "@var bool: Whether the extension should be enabled as an opt-in beta feature. If true, the BetaFeatures extension must be installed. False by default.",
"PopupsBetaFeature": false,
"@SchemaPopupsSamplingRate": "@var number: Sample rate for logging events to Schema:Popups.",
"SchemaPopupsSamplingRate": 0,
"@PopupsSchemaSamplingRate": "@var number: Sample rate for logging events to Schema:Popups.",
"PopupsSchemaSamplingRate": 0,
"@PopupsHideOptInOnPreferencesPage": "@var bool: Whether the option to senable/disable Page Previews should be hidden on Preferences page. Please note if PopupsBetaFeature is set to true this option will be always hidden. False by default",
"PopupsHideOptInOnPreferencesPage": false,
"@PopupsOptInDefaultState" : "@var string:['1'|'0'] Default Page Previews visibility. Has to be a string as a compatibility with beta feature settings",

View file

@ -9,7 +9,7 @@
* @return {mw.eventLog.Schema}
*/
mw.popups.createSchema = function ( config, window ) {
var samplingRate = config.get( 'wgPopupsSchemaPopupsSamplingRate', 0 );
var samplingRate = config.get( 'wgPopupsSchemaSamplingRate', 0 );
if (
!window.navigator ||

View file

@ -189,10 +189,10 @@ class PopupsHooksTest extends MediaWikiTestCase {
public function testOnResourceLoaderGetConfigVars() {
$vars = [ 'something' => 'notEmpty' ];
$value = 10;
$this->setMwGlobals( [ 'wgSchemaPopupsSamplingRate' => $value ] );
$this->setMwGlobals( [ 'wgPopupsSchemaSamplingRate' => $value ] );
PopupsHooks::onResourceLoaderGetConfigVars( $vars );
$this->assertCount( 2, $vars );
$this->assertEquals( $value, $vars[ 'wgPopupsSchemaPopupsSamplingRate' ] );
$this->assertEquals( $value, $vars[ 'wgPopupsSchemaSamplingRate' ] );
}
/**

View file

@ -3,7 +3,7 @@
QUnit.module( 'ext.popups/schema', {
setup: function () {
this.config = new mw.Map();
this.config.set( 'wgPopupsSchemaPopupsSamplingRate', 1 );
this.config.set( 'wgPopupsSchemaSamplingRate', 1 );
this.window = {
navigator: {
@ -16,7 +16,7 @@
}
} );
QUnit.test( 'it should use $wgPopupsSchemaPopupsSamplingRate as the sampling rate', function ( assert ) {
QUnit.test( 'it should use $wgPopupsSchemaSamplingRate as the sampling rate', function ( assert ) {
assert.expect( 2 );
mw.popups.createSchema( this.config, this.window );
@ -29,7 +29,7 @@
assert.ok(
mw.eventLog.Schema.calledWith( 'Popups', 0 ),
'If $wgPopupsSchemaPopupsSamplingRate isn\'t set, then the sampling rate should be 0.'
'If $wgPopupsSchemaSamplingRate isn\'t set, then the sampling rate should be 0.'
);
} );