From: Bartosz DziewoƄski Date: Mon, 30 Mar 2015 17:08:55 +0000 (+0200) Subject: ResourceLoaderImage: Throw exception if files don't exist X-Git-Tag: 1.31.0-rc.0~11914^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/?a=commitdiff_plain;h=2d5d8b53637b75d4e0f3c5e07c804d89ca4f2e86;p=lhc%2Fweb%2Fwiklou.git ResourceLoaderImage: Throw exception if files don't exist Change-Id: I67eb795f7fc4d35d15feb0717b1b781cbc45f78a --- 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 ); }