Don't attempt to call methods on $file if it's not an object

This fixes a fatal which is blocking deployment of 1.29.0-wmf.1
refs T149059 fixes T149849

Bug: 149849
Change-Id: Ieb61585af3aa60b7af58597091151d0b494b2fd6
This commit is contained in:
Mukunda Modell 2016-11-03 13:27:32 -05:00 committed by 20after4
parent 912335ce39
commit c399c4156e

View file

@ -145,9 +145,8 @@ class ApiQueryPageImages extends ApiQueryBase {
$vals = array();
if ( isset( $prop['thumbnail'] ) || isset( $prop['original'] ) ) {
$file = wfFindFile( $fileName );
if ( isset( $prop['thumbnail'] ) ) {
if ( $file ) {
if ( $file ) {
if ( isset( $prop['thumbnail'] ) ) {
$thumb = $file->transform( array( 'width' => $size, 'height' => $size ) );
if ( $thumb && $thumb->getUrl() ) {
// You can request a thumb 1000x larger than the original
@ -161,16 +160,16 @@ class ApiQueryPageImages extends ApiQueryBase {
);
}
}
}
if ( isset( $prop['original'] ) ) {
$original_url = wfExpandUrl( $file->getUrl(), PROTO_CURRENT );
if ( isset( $vals['thumbnail'] ) ) {
$vals['thumbnail']['original'] = $original_url;
} else {
$vals['thumbnail'] = array(
'original' => $original_url,
);
if ( isset( $prop['original'] ) ) {
$original_url = wfExpandUrl( $file->getUrl(), PROTO_CURRENT );
if ( isset( $vals['thumbnail'] ) ) {
$vals['thumbnail']['original'] = $original_url;
} else {
$vals['thumbnail'] = array(
'original' => $original_url,
);
}
}
}
}