r95870 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95869‎ | r95870 | r95871 >
Date:14:37, 31 August 2011
Author:krinkle
Status:deferred (Comments)
Tags:
Comment:
Fix Uncaught TypeError: Cannot call method 'substr' of undefined
* When changing the name of a category and saving it, this error is thrown from $.ucFirst. Although the script does check for it to be a string, what happens between that and ucFirst is broken. It should always set 'category' of splitresult[0], not just if there is a [1] (=sortkey). Otherwise, if there is no sortkey, 'category' is undefined.
* Also updated outdated comment saying that variable sortkey contains wikitext between "[[Category:Foo" and "]]" (which implies it includes the pipe, which is no longer true)

Follows-up r93351.
Modified paths:
  • /trunk/phase3/resources/mediawiki.page/mediawiki.page.ajaxCategories.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.page/mediawiki.page.ajaxCategories.js
@@ -270,20 +270,17 @@
271271 * @param e {jQuery Event}
272272 */
273273 this.handleEditLink = function( e ) {
274 - var input, category, categoryOld,
275 - sortkey = '', // Wikitext for between '[[Category:Foo' and ']]'.
 274+ var input, category, sortkey, categoryOld,
276275 $el = $( this ),
277276 $link = $el.parent().parent().find( 'a:not(.icon)' );
278277
279278 // Grab category text
280279 input = $el.parent().find( '.mw-addcategory-input' ).val();
281280
282 - // Strip sortkey
 281+ // Split categoryname and sortkey
283282 var arr = input.split( '|', 2 );
284 - if ( arr.length > 1 ) {
285 - category = arr[0];
286 - sortkey = arr[1];
287 - }
 283+ category = arr[0];
 284+ sortkey = arr[1]; // Is usually undefined, ie. if there was no '|' in the input.
288285
289286 // Grab text
290287 var isAdded = $link.hasClass( 'mw-added-category' );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93351AjaxCategories rewrite:...krinkle00:43, 28 July 2011

Comments

#Comment by Krinkle (talk | contribs)   20:57, 3 October 2011

AjaxCategories moved out of core. Marking deferred for now.

Status & tagging log