From: Fomafix Date: Sun, 16 Jun 2019 09:20:11 +0000 (+0200) Subject: resourceloader: Throw exception in ResourceLoaderImage::getPath X-Git-Tag: 1.34.0-rc.0~1299^2 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=44de6a6255615933c15d3c0c33a2aedcc95e7d1e;p=lhc%2Fweb%2Fwiklou.git resourceloader: Throw exception in ResourceLoaderImage::getPath Throw an exception in ResourceLoaderImage::getPath when there is no matching path instead of continue with null. Change-Id: I677f4a53f4c90af27db0cc2fd8ef5f028fb49168 --- diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php index 2e2da70475..c1b3dc34ca 100644 --- a/includes/resourceloader/ResourceLoaderImage.php +++ b/includes/resourceloader/ResourceLoaderImage.php @@ -146,6 +146,7 @@ class ResourceLoaderImage { * * @param ResourceLoaderContext $context Any context * @return string + * @throws MWException If no matching path is found */ public function getPath( ResourceLoaderContext $context ) { $desc = $this->descriptor; @@ -167,7 +168,11 @@ class ResourceLoaderImage { if ( isset( $desc[$context->getDirection()] ) ) { return $this->basePath . '/' . $desc[$context->getDirection()]; } - return $this->basePath . '/' . $desc['default']; + if ( isset( $desc['default'] ) ) { + return $this->basePath . '/' . $desc['default']; + } else { + throw new MWException( 'No matching path found' ); + } } /**