r109017 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109016‎ | r109017 | r109018 >
Date:03:42, 16 January 2012
Author:yaron
Status:resolved (Comments)
Tags:semanticforms 
Comment:
Revert of r108255 - too early to get rid of JS globals, since SF still supports MW 1.16. Hopefully these changes can be restored in the next six months or so, though
Modified paths:
  • /trunk/extensions/SemanticForms/libs/SF_ajax_form_preview.js (modified) (history)
  • /trunk/extensions/SemanticForms/libs/SF_autoedit.js (modified) (history)
  • /trunk/extensions/SemanticForms/libs/SF_imagePreview.js (modified) (history)
  • /trunk/extensions/SemanticForms/libs/SF_submit.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/libs/SF_autoedit.js
@@ -8,7 +8,7 @@
99
1010 $('.autoedit-trigger').click(function(){
1111
12 - if ( mw.config.get( 'wgUserName' ) == null ) {
 12+ if ( wgUserName == null ) {
1313 if ( confirm( sfgAnonEditWarning ) ) {
1414 handleAutoEdit( this );
1515 }
Index: trunk/extensions/SemanticForms/libs/SF_submit.js
@@ -7,7 +7,7 @@
88 var sacButtons;
99 var form;
1010
11 - if ( mw.config.get( 'wgAction' ) === "formedit" || mw.config.get( 'wgCanonicalSpecialPageName' ) === "FormEdit" ) {
 11+ if ( wgAction === "formedit" || wgCanonicalSpecialPageName === "FormEdit" ) {
1212
1313 form = $('#sfForm');
1414
@@ -130,16 +130,16 @@
131131
132132 }
133133
134 - if (mw.config.get( 'wgAction' ) == "formedit") {
135 - params += "&target=" + encodeURIComponent( mw.config.get( 'wgPageName' ) );
136 - } else if ( mw.config.get( 'wgCanonicalSpecialPageName' ) == "FormEdit") {
 134+ if (wgAction == "formedit") {
 135+ params += "&target=" + encodeURIComponent( wgPageName );
 136+ } else if ( wgCanonicalSpecialPageName == "FormEdit") {
137137
138138 var url = String(window.location);
139139
140140 var stop = url.indexOf("?");
141141 if ( stop > 0 ) url = url.substring(0, stop);
142142
143 - var start = url.indexOf( mw.config.get( 'wgPageName' ) ); // find start of page name
 143+ var start = url.indexOf( wgPageName ); // find start of page name
144144 start = url.indexOf("/", start) + 1; // find start of subpage
145145
146146 if ( start >= 0 ) {
Index: trunk/extensions/SemanticForms/libs/SF_imagePreview.js
@@ -11,7 +11,7 @@
1212
1313 this.getPreviewImage = function( args, callback ) {
1414 $.getJSON(
15 - mw.config.get( 'wgScriptPath' ) + '/api.php',
 15+ wgScriptPath + '/api.php',
1616 {
1717 'action': 'query',
1818 'format': 'json',
Index: trunk/extensions/SemanticForms/libs/SF_ajax_form_preview.js
@@ -10,7 +10,7 @@
1111
1212 function ajaxFormPreviewInit(){
1313
14 - if ((mw.config.get( 'wgNamespaceNumber' ) % 2 == 0) && /\.(js|css)$/.test(mw.config.get( 'wgTitle' ))) return;
 14+ if ((wgNamespaceNumber % 2 == 0) && /\.(js|css)$/.test(wgTitle)) return;
1515
1616 if(!document.getElementById('wikiPreview')) return;
1717
@@ -63,7 +63,7 @@
6464
6565 //prepare
6666 var action = document.URL;
67 - if (mw.config.get( 'wgAction' )=='formedit') action += '&live';
 67+ if (wgAction=='formedit') action += '&live';
6868
6969 var boundary = '--------123xyz';
7070 var data = '';
@@ -253,6 +253,6 @@
254254 }
255255 }
256256
257 -if ( mw.config.get( 'wgAction' ) ==='formedit' || mw.config.get( 'wgCanonicalSpecialPageName' ) === 'FormEdit' ) {
 257+if ( wgAction ==='formedit' || wgCanonicalSpecialPageName === 'FormEdit' ) {
258258 jQuery( ajaxFormPreviewInit );
259259 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r112138Follow-up to r108225 and r109017 - re-did nikerabbit's replacement of JS glob...yaron19:37, 22 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r108225Blind search and replace to get rid of legacy globals - untestednikerabbit12:29, 6 January 2012

Comments

#Comment by Nikerabbit (talk | contribs)   07:18, 16 January 2012

I guess I need to disable SemanticForms on translatewiki.net then.

#Comment by Yaron Koren (talk | contribs)   13:14, 16 January 2012

Why is that?

#Comment by Nikerabbit (talk | contribs)   13:46, 21 February 2012

Because it doesn't work without legacy globals.

#Comment by Yaron Koren (talk | contribs)   14:19, 21 February 2012

Sorry - I don't know what you mean here. Does the latest MW no longer support globals?

#Comment by Krinkle (talk | contribs)   13:51, 21 February 2012

Cmon please branch code. You can't expect this to work all the way from 1.16 to 1.20.

#Comment by Yaron Koren (talk | contribs)   14:20, 21 February 2012

I'm not going to branch the extension just for this one thing. If using JS globals no longer works with the latest MW, I'll just remove them.

#Comment by Nikerabbit (talk | contribs)   14:26, 21 February 2012

It is a configuration setting I've enabled on translatewiki.net to catch and fix problems.

#Comment by Yaron Koren (talk | contribs)   17:17, 21 February 2012

Ah - I didn't know that having JS globals could cause problems. Well, that changes the situation - I guess we might as well drop support for MW 1.16 in SF already. So, I'll re-add your changes - or feel free to do that yourself.

#Comment by Krinkle (talk | contribs)   14:57, 21 February 2012

... that is $wgLegacyJavaScriptGlobals .

What do you mean by "removing them". ?

#Comment by Yaron Koren (talk | contribs)   17:17, 21 February 2012

i.e., redo Nikerabbit's changes.

#Comment by Krinkle (talk | contribs)   13:52, 21 February 2012

1.16 isn't even supported as major release any more. "Legacy supported release" is currently 1.17.2 according to Download.

Status & tagging log