Merge "objectcache: move MemcachedClient class to /utils subdir"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderImage.php
index 5b39fc7..6497543 100644 (file)
@@ -226,10 +226,13 @@ class ResourceLoaderImage {
                        'image' => $this->getName(),
                        'variant' => $variant,
                        'format' => $format,
-                       'lang' => $context->getLanguage(),
-                       'skin' => $context->getSkin(),
-                       'version' => $context->getVersion(),
                ];
+               if ( $this->varyOnLanguage() ) {
+                       $query['lang'] = $context->getLanguage();
+               }
+               // The following parameters are at the end to keep the original order of the parameters.
+               $query['skin'] = $context->getSkin();
+               $query['version'] = $context->getVersion();
 
                return wfAppendQuery( $script, $query );
        }
@@ -434,7 +437,8 @@ class ResourceLoaderImage {
 
                        file_put_contents( $tempFilenameSvg, $svg );
 
-                       $metadata = SVGMetadataExtractor::getMetadata( $tempFilenameSvg );
+                       $svgReader = new SVGReader( $tempFilenameSvg );
+                       $metadata = $svgReader->getMetadata();
                        if ( !isset( $metadata['width'] ) || !isset( $metadata['height'] ) ) {
                                unlink( $tempFilenameSvg );
                                return false;
@@ -458,4 +462,16 @@ class ResourceLoaderImage {
                        return $png ?: false;
                }
        }
+
+       /**
+        * Check if the image depends on the language.
+        *
+        * @return bool
+        */
+       private function varyOnLanguage() {
+               return is_array( $this->descriptor ) && (
+                       isset( $this->descriptor['ltr'] ) ||
+                       isset( $this->descriptor['rtl'] ) ||
+                       isset( $this->descriptor['lang'] ) );
+       }
 }