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
This commit is contained in:
Moriel Schottlender 2015-02-11 15:16:23 -08:00 committed by Mooeypoo
parent 0d3bd68431
commit 65d0a9d7e7

View file

@ -190,6 +190,14 @@ ve.dm.MWMediaResourceProvider.prototype.fetchAPIresults = function ( howMany ) {
if ( raw ) { if ( raw ) {
// Strip away the page ids // Strip away the page ids
for ( page in raw ) { 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 = raw[page].imageinfo[0];
newObj.title = raw[page].title; newObj.title = raw[page].title;
results.push( newObj ); results.push( newObj );