From 2d5d8b53637b75d4e0f3c5e07c804d89ca4f2e86 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Mon, 30 Mar 2015 19:08:55 +0200 Subject: [PATCH] ResourceLoaderImage: Throw exception if files don't exist Change-Id: I67eb795f7fc4d35d15feb0717b1b781cbc45f78a --- includes/resourceloader/ResourceLoaderImage.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php index d12975a548..758ee7c30d 100644 --- a/includes/resourceloader/ResourceLoaderImage.php +++ b/includes/resourceloader/ResourceLoaderImage.php @@ -191,6 +191,7 @@ class ResourceLoaderImage { * @param string $format Format to get the data for, 'original' or 'rasterized'. Optional, if * given, overrides the data from $context. * @return string|false Possibly binary image data, or false on failure + * @throws MWException If the image file doesn't exist */ public function getImageData( ResourceLoaderContext $context, $variant = false, $format = false ) { if ( $variant === false ) { @@ -201,6 +202,10 @@ class ResourceLoaderImage { } $path = $this->getPath( $context ); + if ( !file_exists( $path ) ) { + throw new MWException( "File '$path' does not exist" ); + } + if ( $this->getExtension() !== 'svg' ) { return file_get_contents( $path ); } -- 2.20.1