MWCategoryInputWidget: Don't explode on invalid titles

canonicalQueryValue can be null at this point, so let's not insert it
into an array that contains strings.

Bug: T76868
Change-Id: I8096a9c1017e883d28124bf807d2d375ae98452a
This commit is contained in:
Bartosz Dziewoński 2014-12-05 21:07:57 +01:00
parent b0b53befdc
commit d39dfaa837

View file

@ -112,9 +112,10 @@ ve.ui.MWCategoryInputWidget.prototype.getLookupMenuItemsFromData = function ( da
prefixedCanonicalQueryValue = prefixedCanonicalQueryValue && prefixedCanonicalQueryValue.getPrefixedText();
// Invalid titles end up with canonicalQueryValue being null.
if ( canonicalQueryValue ) {
canonicalQueryValue = canonicalQueryValue.getMainText();
} // Invalid titles just end up with canonicalQueryValue being null.
}
$.each( data, function ( index, suggestedCategory ) {
var suggestedCategoryTitle = mw.Title.newFromText(
@ -151,7 +152,7 @@ ve.ui.MWCategoryInputWidget.prototype.getLookupMenuItemsFromData = function ( da
} );
// New category
if ( !exactMatch ) {
if ( !exactMatch && canonicalQueryValue ) {
newCategoryItems.push( canonicalQueryValue );
linkCacheUpdate[prefixedCanonicalQueryValue] = { missing: true };
}