mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 14:33:59 +00:00
Check for normalized and converted titles in ve.init.mw.ApiResponseCache
Besides redirects, API can return from-to title pairs for normalized and converted titles, as well. Currently, doing an API query on eswiki for page info (prop='info' in params) with titles='User:Title' returns normalized title 'Usuario:Title'. processResult() method in ve.init.mw.ApiResponseCache.prototype.processQueue sets page.title ('Usuario:Title') in cached results, and the promise for actual queried title ('User:Title') gets rejected in rejectSubqueue() method. Change-Id: I33fd4640b6eac8018e35c6fe21234f4c469dd97d
This commit is contained in:
parent
5c48ef286a
commit
86615fcedc
|
@ -160,11 +160,14 @@ ve.init.mw.ApiResponseCache.prototype.processQueue = function () {
|
|||
}
|
||||
|
||||
function processResult( data ) {
|
||||
var i, pageid, page, processedPage, redirects,
|
||||
var i, pageid, page, processedPage, from, mappedTitles = [],
|
||||
pages = ( data.query && data.query.pages ) || data.pages,
|
||||
processed = {};
|
||||
|
||||
redirects = ( data.query && data.query.redirects ) || [];
|
||||
[ 'redirects', 'normalized', 'converted' ].forEach( function ( map ) {
|
||||
mappedTitles = mappedTitles.concat( ( data.query && data.query[ map ] ) || [] );
|
||||
} );
|
||||
|
||||
if ( pages ) {
|
||||
for ( pageid in pages ) {
|
||||
page = pages[ pageid ];
|
||||
|
@ -173,10 +176,13 @@ ve.init.mw.ApiResponseCache.prototype.processQueue = function () {
|
|||
processed[ page.title ] = processedPage;
|
||||
}
|
||||
}
|
||||
for ( i = 0; i < redirects.length; i++ ) {
|
||||
// Locate the title in redirects, if any.
|
||||
if ( redirects[ i ].to === page.title ) {
|
||||
processed[ redirects[ i ].from ] = processedPage;
|
||||
for ( i = 0; i < mappedTitles.length; i++ ) {
|
||||
// Locate the title in mapped titles, if any.
|
||||
if ( mappedTitles[ i ].to === page.title ) {
|
||||
from = mappedTitles[ i ].fromencoded === '' ?
|
||||
decodeURIComponent( mappedTitles[ i ].from ) :
|
||||
mappedTitles[ i ].from;
|
||||
processed[ from ] = processedPage;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue