From 3ffc32ab8b19fcc94f942e5d0a5678eb87474ca1 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Mon, 17 Sep 2018 22:14:53 +0200 Subject: [PATCH] ProtectionForm: Move JS config var to RL packageFiles The check for type Array of the JavaScript config variable is obsolete. Change-Id: I4a38cfc211360c831958ce8ca88584cdf56a727c --- includes/ProtectionForm.php | 3 --- resources/Resources.php | 7 ++++++- resources/src/mediawiki.legacy/protect.js | 13 +++---------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/includes/ProtectionForm.php b/includes/ProtectionForm.php index c677a09102..6ce7ef4757 100644 --- a/includes/ProtectionForm.php +++ b/includes/ProtectionForm.php @@ -353,12 +353,9 @@ class ProtectionForm { $user = $context->getUser(); $output = $context->getOutput(); $lang = $context->getLanguage(); - $conf = $context->getConfig(); - $cascadingRestrictionLevels = $conf->get( 'CascadingRestrictionLevels' ); $out = ''; if ( !$this->disabled ) { $output->addModules( 'mediawiki.legacy.protect' ); - $output->addJsConfigVars( 'wgCascadeableLevels', $cascadingRestrictionLevels ); $out .= Xml::openElement( 'form', [ 'method' => 'post', 'action' => $this->mTitle->getLocalURL( 'action=protect' ), 'id' => 'mw-Protect-Form' ] ); diff --git a/resources/Resources.php b/resources/Resources.php index d62f3e3c54..f2264277d8 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -2386,7 +2386,12 @@ return [ ], ], 'mediawiki.legacy.protect' => [ - 'scripts' => 'resources/src/mediawiki.legacy/protect.js', + 'localBasePath' => "$IP/resources/src/mediawiki.legacy", + 'remoteBasePath' => "$wgResourceBasePath/resources/src/mediawiki.legacy", + 'packageFiles' => [ + 'protect.js', + 'config.json' => [ 'config' => [ 'CascadingRestrictionLevels' ] ], + ], 'dependencies' => 'jquery.lengthLimit', 'messages' => [ 'protect-unchain-permissions' ] ], diff --git a/resources/src/mediawiki.legacy/protect.js b/resources/src/mediawiki.legacy/protect.js index 73978d9ba6..b3707a5267 100644 --- a/resources/src/mediawiki.legacy/protect.js +++ b/resources/src/mediawiki.legacy/protect.js @@ -1,5 +1,6 @@ ( function () { var ProtectionForm, + config = require( './config.json' ), reasonCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ), reasonByteLimit = mw.config.get( 'wgCommentByteLimit' ); @@ -18,9 +19,7 @@ return false; } - if ( mw.config.get( 'wgCascadeableLevels' ) !== undefined ) { - $( 'form#mw-Protect-Form' ).on( 'submit', this.toggleUnchainedInputs.bind( ProtectionForm, true ) ); - } + $( 'form#mw-Protect-Form' ).on( 'submit', this.toggleUnchainedInputs.bind( ProtectionForm, true ) ); this.getExpirySelectors().each( function () { $( this ).on( 'change', ProtectionForm.updateExpiryList.bind( ProtectionForm, this ) ); } ); @@ -81,13 +80,7 @@ * @return {boolean} */ isCascadeableLevel: function ( level ) { - var cascadeableLevels = mw.config.get( 'wgCascadeableLevels' ); - - if ( !Array.isArray( cascadeableLevels ) ) { - return false; - } - - return cascadeableLevels.indexOf( level ) !== -1; + return config.CascadingRestrictionLevels.indexOf( level ) !== -1; }, /** -- 2.20.1