r87410 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87409‎ | r87410 | r87411 >
Date:16:34, 4 May 2011
Author:neilk
Status:resolved (Comments)
Tags:
Comment:
obtain URL from page title of alternate upload form
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -666,6 +666,7 @@
667667 );
668668 $j( '#contentSub' ).append( feedbackLink );
669669 }
 670+
670671 if ( mw.isDefined( mw.UploadWizard.config['bugList'] ) && mw.UploadWizard.config['bugList'] !== '' ) {
671672 $j( '#contentSub' ).append( $j( '<span class="contentSubLink"></span>' ).msg( 'mwe-upwiz-subhead-bugs', $j( '<a></a>' ).attr( { href: mw.UploadWizard.config['bugList'], target: '_blank' } ) ) );
672673 }
@@ -673,7 +674,9 @@
674675 $j( '#contentSub' ).append( $j( '<span class="contentSubLink"></span>' ).msg( 'mwe-upwiz-subhead-translate', $j( '<a></a>' ).attr( { href: mw.UploadWizard.config['translateHelp'], target: '_blank' } ) ) );
675676 }
676677 if ( mw.isDefined( mw.UploadWizard.config['altUploadForm'] ) && mw.UploadWizard.config['altUploadForm'] !== '' ) {
677 - $j( '#contentSub' ).append( $j( '<span class="contentSubLink"></span>' ).msg( 'mwe-upwiz-subhead-alt-upload', $j( '<a></a>' ).attr( { href: mw.UploadWizard.config['altUploadForm'], target: '_blank' } ) ) );
 678+ // altUploadForm is expected to be a page title like 'Commons:Upload', so convert to URL
 679+ var altUploadFormUrl = ( new mw.Title( mw.UploadWizard.config['altUploadForm'] ) ).getUrl();
 680+ $j( '#contentSub' ).append( $j( '<span class="contentSubLink"></span>' ).msg( 'mwe-upwiz-subhead-alt-upload', $j( '<a></a>' ).attr( { href: altUploadFormUrl } ) ) );
678681 }
679682 $j( '#contentSub .contentSubLink:not(:last)' ).after( '&nbsp;&middot;&nbsp;' );
680683

Follow-up revisions

RevisionCommit summaryAuthorDate
r87772followup to r87410 -- trap errors for mw.Title properlyneilk21:06, 9 May 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   20:05, 9 May 2011

Doesn't check for errors; mw.Title() constructor appears to throw an exception on some invalid input -- and also on what appears to be perfectly valid input such as 'Commonsx:Upload' (throws "unrecognized namespace prefix", which it should not -- that should just come through as the local page titled 'Commonsx:Upload').

If given invalid input, should probably fall back to the standard link or at least rethrow the error with specificity, so the console error log shows that it was a problem with the altUploadForm setting for UploadWizard extension.

#Comment by Brion VIBBER (talk | contribs)   20:10, 9 May 2011

Looks like mw.Title is UploadWizard-specific, not part of MediaWiki core.

#Comment by Brion VIBBER (talk | contribs)   20:48, 9 May 2011

Whether this is ok for now depends on whether initial configuration could include an interwiki link or faux-namespace local link for this setting; eg 'Commons:Upload' will fail on a site other than Wikimedia Commons, as there's no local 'Commons' namespace.

#Comment by NeilK (talk | contribs)   21:06, 9 May 2011

excellent catch. most people wouldn't go looking for exceptions. :)

fixed in r87772 (I tested impossible pages like Spockial:Upload...)

#Comment by Brion VIBBER (talk | contribs)   21:12, 9 May 2011

Whee!

Status & tagging log