From: Brad Jorsch Date: Tue, 9 Jan 2018 15:19:39 +0000 (-0500) Subject: ApiQueryImageInfo: Don't return URLs if the archived file is missing X-Git-Tag: 1.31.0-rc.0~947^2 X-Git-Url: http://git.cyclocoop.org///%22%40url%40//%22?a=commitdiff_plain;h=af716f64e3c89dc0c52f1045425f35da113ca93c;p=lhc%2Fweb%2Fwiklou.git ApiQueryImageInfo: Don't return URLs if the archived file is missing If the archived file doesn't exist, indicate that instead of returning bogus URLs. Bug: T184445 Change-Id: I831b13314300f0289a2baf26ed21d81be31b292a --- diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index b1df982da7..0603923230 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -503,32 +503,36 @@ class ApiQueryImageInfo extends ApiQueryBase { } if ( $url ) { - if ( !is_null( $thumbParams ) ) { - $mto = $file->transform( $thumbParams ); - self::$transformCount++; - if ( $mto && !$mto->isError() ) { - $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT ); - - // T25834 - If the URLs are the same, we haven't resized it, so shouldn't give the wanted - // thumbnail sizes for the thumbnail actual size - if ( $mto->getUrl() !== $file->getUrl() ) { - $vals['thumbwidth'] = intval( $mto->getWidth() ); - $vals['thumbheight'] = intval( $mto->getHeight() ); - } else { - $vals['thumbwidth'] = intval( $file->getWidth() ); - $vals['thumbheight'] = intval( $file->getHeight() ); - } + if ( $file->exists() ) { + if ( !is_null( $thumbParams ) ) { + $mto = $file->transform( $thumbParams ); + self::$transformCount++; + if ( $mto && !$mto->isError() ) { + $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT ); + + // T25834 - If the URLs are the same, we haven't resized it, so shouldn't give the wanted + // thumbnail sizes for the thumbnail actual size + if ( $mto->getUrl() !== $file->getUrl() ) { + $vals['thumbwidth'] = intval( $mto->getWidth() ); + $vals['thumbheight'] = intval( $mto->getHeight() ); + } else { + $vals['thumbwidth'] = intval( $file->getWidth() ); + $vals['thumbheight'] = intval( $file->getHeight() ); + } - if ( isset( $prop['thumbmime'] ) && $file->getHandler() ) { - list( , $mime ) = $file->getHandler()->getThumbType( - $mto->getExtension(), $file->getMimeType(), $thumbParams ); - $vals['thumbmime'] = $mime; + if ( isset( $prop['thumbmime'] ) && $file->getHandler() ) { + list( , $mime ) = $file->getHandler()->getThumbType( + $mto->getExtension(), $file->getMimeType(), $thumbParams ); + $vals['thumbmime'] = $mime; + } + } elseif ( $mto && $mto->isError() ) { + $vals['thumberror'] = $mto->toText(); } - } elseif ( $mto && $mto->isError() ) { - $vals['thumberror'] = $mto->toText(); } + $vals['url'] = wfExpandUrl( $file->getFullUrl(), PROTO_CURRENT ); + } else { + $vals['filemissing'] = true; } - $vals['url'] = wfExpandUrl( $file->getFullUrl(), PROTO_CURRENT ); $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT ); $shortDescriptionUrl = $file->getDescriptionShortUrl();