r103523 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103522‎ | r103523 | r103524 >
Date:23:28, 17 November 2011
Author:raindrift
Status:resolved (Comments)
Tags:
Comment:
Category autocomplete now only suggests categories that have corresponding description pages. Fixes bug 30718
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.Api.category.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.Api.category.js
@@ -42,18 +42,20 @@
4343 */
4444 getCategoriesByPrefix: function( prefix, callback, err ) {
4545
 46+ // fetch with allpages to only get categories that have a corresponding description page.
4647 var params = {
47 - 'list': 'allcategories',
48 - 'acprefix': prefix
 48+ 'list': 'allpages',
 49+ 'apprefix': prefix,
 50+ 'apnamespace': mw.config.get('wgNamespaceIds').category
4951 };
5052
5153 var ok = function( data ) {
5254 var texts = [];
53 - if ( data.query && data.query.allcategories ) {
 55+ if ( data.query && data.query.allpages ) {
5456 // API returns an array of objects like
55 - // allcategories: [ {'*':'foo'}, {'*':'bar'} ]
56 - $.each( data.query.allcategories, function( i, category ) {
57 - texts.push( category['*'] );
 57+ // allpages: [ {'*':'foo'}, {'*':'bar'} ]
 58+ $.each( data.query.allpages, function( i, category ) {
 59+ texts.push( category.title.substr(9) ); // the substr removes Category: from the title.
5860 } );
5961 }
6062 callback( texts );

Follow-up revisions

RevisionCommit summaryAuthorDate
r105628language-neutral category namesneilk00:24, 9 December 2011

Comments

#Comment by Nikerabbit (talk | contribs)   09:48, 15 December 2011
texts.push( category.title.substr(9) ); // the substr removes Category: from the title.

This only works in English language wikis.

#Comment by Raindrift (talk | contribs)   22:36, 16 December 2011

Good point! I'll split on the colon instead.

#Comment by Raindrift (talk | contribs)   23:48, 16 December 2011

Looks like neilk already fixed this in r105628

Status & tagging log