From 44de6a6255615933c15d3c0c33a2aedcc95e7d1e Mon Sep 17 00:00:00 2001 From: Fomafix Date: Sun, 16 Jun 2019 11:20:11 +0200 Subject: [PATCH] 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 --- includes/resourceloader/ResourceLoaderImage.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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' ); + } } /** -- 2.20.1