r83817 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83816‎ | r83817 | r83818 >
Date:10:55, 13 March 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
(bug 27515) Reintroduce JS variables wgVectorEnabledModules and wgWikiEditorEnabledModules for backwards compatibility
Modified paths:
  • /trunk/extensions/Vector/Vector.hooks.php (modified) (history)
  • /trunk/extensions/Vector/Vector.php (modified) (history)
  • /trunk/extensions/WikiEditor/WikiEditor.hooks.php (modified) (history)
  • /trunk/extensions/WikiEditor/WikiEditor.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiEditor/WikiEditor.php
@@ -56,6 +56,7 @@
5757 $wgHooks['EditPage::showEditForm:initial'][] = 'WikiEditorHooks::editPageShowEditFormInitial';
5858 $wgHooks['GetPreferences'][] = 'WikiEditorHooks::getPreferences';
5959 $wgHooks['ResourceLoaderGetConfigVars'][] = 'WikiEditorHooks::resourceLoaderGetConfigVars';
 60+$wgHooks['MakeGlobalVariablesScript'][] = 'WikiEditorHooks::makeGlobalVariablesScript';
6061
6162 $wikiEditorTpl = array(
6263 'localBasePath' => dirname( __FILE__ ) . '/modules',
Index: trunk/extensions/WikiEditor/WikiEditor.hooks.php
@@ -244,4 +244,17 @@
245245 }
246246 return true;
247247 }
 248+
 249+ public static function makeGlobalVariablesScript( &$vars ) {
 250+ global $wgWikiEditorFeatures;
 251+
 252+ // Build and export old-style wgWikiEditorEnabledModules object for back compat
 253+ $enabledModules = array();
 254+ foreach ( self::$features as $name => $feature ) {
 255+ $enabledModules[$name] = self::isEnabled( $name );
 256+ }
 257+
 258+ $vars['wgWikiEditorEnabledModules'] = $enabledModules;
 259+ return true;
 260+ }
248261 }
Index: trunk/extensions/Vector/Vector.php
@@ -59,6 +59,7 @@
6060 $wgHooks['BeforePageDisplay'][] = 'VectorHooks::beforePageDisplay';
6161 $wgHooks['GetPreferences'][] = 'VectorHooks::getPreferences';
6262 $wgHooks['ResourceLoaderGetConfigVars'][] = 'VectorHooks::resourceLoaderGetConfigVars';
 63+$wgHooks['MakeGlobalVariablesScript'][] = 'VectorHooks::makeGlobalVariablesScript';
6364
6465 $vectorResourceTemplate = array(
6566 'localBasePath' => dirname( __FILE__ ) . '/modules',
Index: trunk/extensions/Vector/Vector.hooks.php
@@ -174,4 +174,17 @@
175175 }
176176 return true;
177177 }
 178+
 179+ public static function makeGlobalVariablesScript( &$vars ) {
 180+ global $wgVectorFeatures;
 181+
 182+ // Build and export old-style wgVectorEnabledModules object for back compat
 183+ $enabledModules = array();
 184+ foreach ( self::$features as $name => $feature ) {
 185+ $enabledModules[$name] = self::isEnabled( $name );
 186+ }
 187+
 188+ $vars['wgVectorEnabledModules'] = $enabledModules;
 189+ return true;
 190+ }
178191 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r844201.17wmf1: MFT r76372, r76377, r83586, r83587, r83817, r83876, r83979, r84118,...catrope21:04, 20 March 2011
r85033MFT more extension revs: r82601, r82654, r82698, r82755, r82756, r82759, r829...demon18:49, 30 March 2011

Comments

#Comment by Krinkle (talk | contribs)   22:58, 16 March 2011

These don't actually work right ? They're just dummies for scripts to play with ?

#Comment by Catrope (talk | contribs)   16:19, 17 March 2011

They're now read-only instead of read-write, if that's what you mean.

#Comment by Krinkle (talk | contribs)   17:24, 22 March 2011

Afaik read-only doesn't exist (yet) in mw.config, I just see

"wgVectorEnabledModules": {"collapsiblenav": true, "collapsibletabs": true, "editwarning": false, "expandablesearch": false, "footercleanup": false, "sectioneditlinks": false, "simplesearch": true, "experiments": true}, "wgWikiEditorEnabledModules": {"toolbar": true, "dialogs": true, "templateEditor": false, "templates": false, "addMediaWizard": false, "preview": false, "previewDialog": false, "publish": false, "toc": false}

.. passed to mw.config from now on.


With dummies I meant that toggling doesn't enable/disable the features ? (Which it did in 1.16wmf when they were toggled before the script initializes). But afaik the javascript doesn't check these anymore (unless I missed a commit re-adding it - can't find "wgVectorEnabledModules" anywhere in the loaded scripts on the client side).

#Comment by Trevor Parscal (WMF) (talk | contribs)   17:42, 22 March 2011

Read-only is probably the wrong phrase. What this is something that is generally useful to read from and generally useless to write to.

#Comment by Krinkle (talk | contribs)   18:18, 22 March 2011

So the transition that was made in 1.16-1.17 (to move control of what's being activated to PHP instead of JS) stays the same, and the variables are now added back as backwards compatibily for what is possible since 1.17 through:

useeditwarning, vector-collapsiblenav, etc. in mw.user.options

Thanks for the clarification :)

#Comment by Trevor Parscal (WMF) (talk | contribs)   15:29, 22 March 2011

Why aren't we doing this with the ResourceLoader global variables hook?

#Comment by Catrope (talk | contribs)   14:49, 23 March 2011

Because the set of enabled modules depends on user preferences.

#Comment by Trevor Parscal (WMF) (talk | contribs)   18:45, 24 March 2011

Good answer. :)

Status & tagging log