resourceloader: Throw exception in ResourceLoaderImage::getPath
authorFomafix <fomafix@googlemail.com>
Sun, 16 Jun 2019 09:20:11 +0000 (11:20 +0200)
committerKrinkle <krinklemail@gmail.com>
Mon, 24 Jun 2019 17:00:33 +0000 (17:00 +0000)
Throw an exception in ResourceLoaderImage::getPath when there is no
matching path instead of continue with null.

Change-Id: I677f4a53f4c90af27db0cc2fd8ef5f028fb49168

includes/resourceloader/ResourceLoaderImage.php

index 2e2da70..c1b3dc3 100644 (file)
@@ -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' );
+               }
        }
 
        /**