ResourceLoaderOOUIIconPackModule: Always use MW core 'localBasePath'
authorBartosz Dziewoński <matma.rex@gmail.com>
Tue, 11 Jun 2019 22:50:02 +0000 (00:50 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 11 Jun 2019 22:56:32 +0000 (00:56 +0200)
Otherwise, extensions defining icon pack modules in extension.json
would need to specify "localBasePath": "../..", which is silly.

Follow-up to a8dae2212cc5e23e181023af2ba1891078b14355.

Change-Id: If8f02867955d649c809b6b41de0f77e594b633d6

includes/resourceloader/ResourceLoaderImageModule.php
includes/resourceloader/ResourceLoaderOOUIIconPackModule.php

index 9b50d80..db292cc 100644 (file)
@@ -113,7 +113,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
         * @throws InvalidArgumentException
         */
        public function __construct( $options = [], $localBasePath = null ) {
-               $this->localBasePath = self::extractLocalBasePath( $options, $localBasePath );
+               $this->localBasePath = static::extractLocalBasePath( $options, $localBasePath );
 
                $this->definition = $options;
        }
index 0c70ee1..c860362 100644 (file)
@@ -69,4 +69,13 @@ class ResourceLoaderOOUIIconPackModule extends ResourceLoaderOOUIImageModule {
 
                return $definition;
        }
+
+       public static function extractLocalBasePath( $options, $localBasePath = null ) {
+               global $IP;
+               if ( $localBasePath === null ) {
+                       $localBasePath = $IP;
+               }
+               // Ignore any 'localBasePath' present in $options, this always refers to files in MediaWiki core
+               return $localBasePath;
+       }
 }