Drop the UserLoadFromSession hook, deprecated in 1.27
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderImage.php
index d10be12..c1b3dc3 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use MediaWiki\Shell\Shell;
+
 /**
  * Class encapsulating an image used in a ResourceLoaderImageModule.
  *
@@ -38,6 +40,21 @@ class ResourceLoaderImage {
                'jpg' => 'image/jpg',
        ];
 
+       /** @var string */
+       private $name;
+       /** @var string */
+       private $module;
+       /** @var string|array */
+       private $descriptor;
+       /** @var string */
+       private $basePath;
+       /** @var array */
+       private $variants;
+       /** @var string|null */
+       private $defaultColor;
+       /** @var string */
+       private $extension;
+
        /**
         * @param string $name Image name
         * @param string $module Module name
@@ -129,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;
@@ -150,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' );
+               }
        }
 
        /**
@@ -373,7 +395,7 @@ class ResourceLoaderImage {
                if ( strpos( $wgSVGConverter, 'rsvg' ) === 0 ) {
                        $command = 'rsvg-convert';
                        if ( $wgSVGConverterPath ) {
-                               $command = wfEscapeShellArg( "$wgSVGConverterPath/" ) . $command;
+                               $command = Shell::escape( "$wgSVGConverterPath/" ) . $command;
                        }
 
                        $process = proc_open(