mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 00:00:49 +00:00
ApiResponseCache: Support redirects data processing
If the mediawiki Api pass redirects as true, the response will have redirect data. ApiResponseCache ignores it now. This commit adds support for processing that and set in the cache. Change-Id: If4f8c9b6719c123b31d852eb71f06a79cc0f7917
This commit is contained in:
parent
5330e42dc7
commit
27d0634abf
|
@ -160,10 +160,11 @@ ve.init.mw.ApiResponseCache.prototype.processQueue = function () {
|
|||
}
|
||||
|
||||
function processResult( data ) {
|
||||
var pageid, page, processedPage,
|
||||
var i, pageid, page, processedPage, redirects,
|
||||
pages = ( data.query && data.query.pages ) || data.pages,
|
||||
processed = {};
|
||||
|
||||
redirects = data.query.redirects || [];
|
||||
if ( pages ) {
|
||||
for ( pageid in pages ) {
|
||||
page = pages[ pageid ];
|
||||
|
@ -172,6 +173,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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
cache.set( processed );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue