Merge "ImageInfoCache: Don't try to access imageinfo result if it's not set"

This commit is contained in:
jenkins-bot 2015-02-28 01:40:52 +00:00 committed by Gerrit Code Review
commit 6c5cb61139
2 changed files with 9 additions and 4 deletions

View file

@ -121,7 +121,7 @@
* Process each page in the response of an API request * Process each page in the response of an API request
* @abstract * @abstract
* @param {Object} page The page object * @param {Object} page The page object
* @return {Object} The relevant info that we want to cache and return. * @return {Object|undefined} Any relevant info that we want to cache and return.
*/ */
ve.init.mw.ApiResponseCache.prototype.processPage = function () { ve.init.mw.ApiResponseCache.prototype.processPage = function () {
throw new Error( 'Stub, override in subclass' ); throw new Error( 'Stub, override in subclass' );
@ -143,14 +143,17 @@
} }
function processResult( data ) { function processResult( data ) {
var pageid, page, var pageid, page, processedPage,
pages = ( data.query && data.query.pages ) || data.pages, pages = ( data.query && data.query.pages ) || data.pages,
processed = {}; processed = {};
if ( pages ) { if ( pages ) {
for ( pageid in pages ) { for ( pageid in pages ) {
page = pages[pageid]; page = pages[pageid];
processed[page.title] = batchQueue.processPage( page ); processedPage = batchQueue.processPage( page );
if ( processedPage !== undefined ) {
processed[page.title] = processedPage;
}
} }
batchQueue.set( processed ); batchQueue.set( processed );
} }

View file

@ -37,6 +37,8 @@
* @inheritdoc * @inheritdoc
*/ */
ve.init.mw.ImageInfoCache.prototype.processPage = function ( page ) { ve.init.mw.ImageInfoCache.prototype.processPage = function ( page ) {
return page.imageinfo[0]; if ( page.imageinfo ) {
return page.imageinfo[0];
}
}; };
}() ); }() );