From c03f57bc119d404469dfd8046acad7626464d813 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Wed, 29 Mar 2017 14:44:22 -0400 Subject: [PATCH] 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 --- includes/resourceloader/ResourceLoaderImage.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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; -- 2.20.1