mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
synced 2024-11-15 03:43:46 +00:00
rest: Verify that file exists before calling filesize
Bug: T252128 Change-Id: I2de87d723fdd99bea0f1dadd23648470759a103e
This commit is contained in:
parent
34f54dd1ad
commit
6e004092ca
|
@ -92,7 +92,9 @@ class SearchResultProvideThumbnailHookHandler {
|
|||
if ( !$thumb ) {
|
||||
continue;
|
||||
}
|
||||
$thumbSize = $thumb->getLocalCopyPath() ? filesize( $thumb->getLocalCopyPath() ) : null;
|
||||
|
||||
$localPath = $thumb->getLocalCopyPath();
|
||||
$thumbSize = $localPath && file_exists( $localPath ) ? filesize( $localPath ) : null;
|
||||
|
||||
$res[$pageId] = new SearchResultThumbnail(
|
||||
$thumb->getFile()->getMimeType(),
|
||||
|
|
|
@ -35,7 +35,7 @@ class SearchResultProvideThumbnailHookHandlerTest extends MediaWikiTestCase {
|
|||
] )
|
||||
->getMock();
|
||||
|
||||
$thumbnail->expects( $this->exactly( $thumbFilePath ? 2 : 1 ) )
|
||||
$thumbnail->expects( $this->once() )
|
||||
->method( 'getLocalCopyPath' )
|
||||
->willReturn( $thumbFilePath );
|
||||
|
||||
|
|
Loading…
Reference in a new issue