X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderFileModule.php;h=af303138f666110b02e2644b830f9bf726324932;hb=bd5a37aacf600bdd5f3a6e7998f92bd1d9326a8a;hp=7093ab1dc0233f0b76610590f10a880ae5aef73a;hpb=b16977ab8e8494313100865424242788f4611e53;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index 7093ab1dc0..af303138f6 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -140,9 +140,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { /** @var bool Link to raw files in debug mode */ protected $debugRaw = true; - /** @var bool Whether mw.loader.state() call should be omitted */ - protected $raw = false; - protected $targets = [ 'desktop' ]; /** @var bool Whether CSSJanus flipping should be skipped for this module */ @@ -259,11 +256,11 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { case 'debugScripts': case 'styles': case 'packageFiles': - $this->{$member} = (array)$option; + $this->{$member} = is_array( $option ) ? $option : [ $option ]; break; case 'templates': $hasTemplates = true; - $this->{$member} = (array)$option; + $this->{$member} = is_array( $option ) ? $option : [ $option ]; break; // Collated lists of file paths case 'languageScripts': @@ -282,7 +279,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { "'$key' given, string expected." ); } - $this->{$member}[$key] = (array)$value; + $this->{$member}[$key] = is_array( $value ) ? $value : [ $value ]; } break; case 'deprecated': @@ -305,7 +302,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { break; // Single booleans case 'debugRaw': - case 'raw': case 'noflip': $this->{$member} = (bool)$option; break; @@ -319,7 +315,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { // Ensure relevant template compiler module gets loaded foreach ( $this->templates as $alias => $templatePath ) { if ( is_int( $alias ) ) { - $alias = $templatePath; + $alias = $this->getPath( $templatePath ); } $suffix = explode( '.', $alias ); $suffix = end( $suffix ); @@ -513,13 +509,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { return $contents; } - /** - * @return bool - */ - public function isRaw() { - return $this->raw; - } - /** * Disable module content versioning. * @@ -620,7 +609,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { 'templates', 'skipFunction', 'debugRaw', - 'raw', ] as $member ) { $options[$member] = $this->{$member}; } @@ -655,6 +643,18 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { return $summary; } + /** + * @param string|ResourceLoaderFilePath $path + * @return string + */ + protected function getPath( $path ) { + if ( $path instanceof ResourceLoaderFilePath ) { + return $path->getPath(); + } + + return $path; + } + /** * @param string|ResourceLoaderFilePath $path * @return string @@ -1004,7 +1004,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { || $this->dependencies || $this->messages || $this->skipFunction - || $this->raw ); return $canBeStylesOnly ? self::LOAD_STYLES : self::LOAD_GENERAL; } @@ -1073,7 +1072,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { foreach ( $this->templates as $alias => $templatePath ) { // Alias is optional if ( is_int( $alias ) ) { - $alias = $templatePath; + $alias = $this->getPath( $templatePath ); } $localPath = $this->getLocalPath( $templatePath ); if ( file_exists( $localPath ) ) { @@ -1160,11 +1159,12 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { throw new MWException( __METHOD__ . ": invalid versionCallback for file" . " \"{$fileInfo['name']}\" in module \"{$this->getName()}\"" ); } - $expanded['definitionSummary'] = ( $fileInfo['versionCallback'] )( $context ); + $expanded['definitionSummary'] = + ( $fileInfo['versionCallback'] )( $context, $this->getConfig() ); // Don't invoke 'callback' here as it may be expensive (T223260). $expanded['callback'] = $fileInfo['callback']; } else { - $expanded['content'] = ( $fileInfo['callback'] )( $context ); + $expanded['content'] = ( $fileInfo['callback'] )( $context, $this->getConfig() ); } } elseif ( isset( $fileInfo['config'] ) ) { if ( $type !== 'data' ) { @@ -1241,7 +1241,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { $fileInfo['content'] = $content; unset( $fileInfo['filePath'] ); } elseif ( isset( $fileInfo['callback'] ) ) { - $fileInfo['content'] = ( $fileInfo['callback'] )( $context ); + $fileInfo['content'] = ( $fileInfo['callback'] )( $context, $this->getConfig() ); unset( $fileInfo['callback'] ); }