From: Roan Kattouw Date: Wed, 29 Mar 2017 18:44:22 +0000 (-0400) Subject: ResourceLoaderImage: Correctly ignore 'deprecated' key X-Git-Tag: 1.31.0-rc.0~3666^2~1 X-Git-Url: http://git.cyclocoop.org//%22javascript:ModifierStyle%28%27%22.%24id.%22%27%29/%22?a=commitdiff_plain;h=c03f57bc119d404469dfd8046acad7626464d813;p=lhc%2Fweb%2Fwiklou.git ResourceLoaderImage: Correctly ignore 'deprecated' key It turns out that 'resources/lib/oojs-ui/themes/mediawiki/Moved since v0.20.1, use from the 'interactions' pack instead.' is not usually an existing file, and doesn't have the extension '.svg'. Not sure why this didn't break earlier. Bonus: Add module name to exceptions to make these errors easier to track down. Bonus #2: Use the post-expansion, not pre-expansion, definition everywhere to avoid confusion when debugging. Change-Id: I0325d4dab5658fd29c3c33fd3e762834b53d1b5d --- diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php index 6a6a3c24d5..19d54714f5 100644 --- a/includes/resourceloader/ResourceLoaderImage.php +++ b/includes/resourceloader/ResourceLoaderImage.php @@ -67,23 +67,27 @@ class ResourceLoaderImage { } } } + // Remove 'deprecated' key + if ( is_array( $this->descriptor ) ) { + unset( $this->descriptor[ 'deprecated' ] ); + } // Ensure that all files have common extension. $extensions = []; - $descriptor = (array)$descriptor; + $descriptor = (array)$this->descriptor; array_walk_recursive( $descriptor, function ( $path ) use ( &$extensions ) { $extensions[] = pathinfo( $path, PATHINFO_EXTENSION ); } ); $extensions = array_unique( $extensions ); if ( count( $extensions ) !== 1 ) { throw new InvalidArgumentException( - "File type for different image files of '$name' not the same" + "File type for different image files of '$name' not the same in module '$module'" ); } $ext = $extensions[0]; if ( !isset( self::$fileTypes[$ext] ) ) { throw new InvalidArgumentException( - "Invalid file type for image files of '$name' (valid: svg, png, gif, jpg)" + "Invalid file type for image files of '$name' (valid: svg, png, gif, jpg) in module '$module'" ); } $this->extension = $ext;