From 65d0a9d7e7fd0a7f506fdc24c5d442a1e9056f2c Mon Sep 17 00:00:00 2001 From: Moriel Schottlender Date: Wed, 11 Feb 2015 15:16:23 -0800 Subject: [PATCH] Defend against empty file pages in media dialog search Empty file pages are returned as results in search but have no useful information, and, more importantly, no 'imageinfo' property. Make sure these are skipped by the provider. Bug: T89303 Change-Id: I3374f7373efc1f5751acb16819973594abf56a56 --- modules/ve-mw/dm/models/ve.dm.MWMediaResourceProvider.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/ve-mw/dm/models/ve.dm.MWMediaResourceProvider.js b/modules/ve-mw/dm/models/ve.dm.MWMediaResourceProvider.js index 43095242e2..78c28a80c3 100644 --- a/modules/ve-mw/dm/models/ve.dm.MWMediaResourceProvider.js +++ b/modules/ve-mw/dm/models/ve.dm.MWMediaResourceProvider.js @@ -190,6 +190,14 @@ ve.dm.MWMediaResourceProvider.prototype.fetchAPIresults = function ( howMany ) { if ( raw ) { // Strip away the page ids for ( page in raw ) { + if ( !raw[page].imageinfo ) { + // The search may give us pages that belong to the File: + // namespace but have no files in them, either because + // they were deleted or imported wrongly, or just started + // as pages. In that case, the response will not include + // imageinfo. Skip those files. + continue; + } newObj = raw[page].imageinfo[0]; newObj.title = raw[page].title; results.push( newObj );