From: Trevor Parscal Date: Thu, 21 Oct 2010 22:34:26 +0000 (+0000) Subject: Fixed missing break; in ResourceLoaderFileModule::__construct, and added extra error... X-Git-Tag: 1.31.0-rc.0~34385 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=0f94d0e00d4ea603bd9bc6d0e115fefddf1b5456;p=lhc%2Fweb%2Fwiklou.git Fixed missing break; in ResourceLoaderFileModule::__construct, and added extra error checking to it's input arrays. --- diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index cd950e8488..5bffad73d6 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -139,9 +139,20 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { case 'languageScripts': case 'skinScripts': case 'skinStyles': - foreach ( (array) $option as $key => $value ) { + if ( !is_array( $option ) ) { + throw new MWException( + "Invalid collated file path list error. '$option' given, array expected." + ); + } + foreach ( $option as $key => $value ) { + if ( !is_string( $key ) ) { + throw new MWException( + "Invalid collated file path list key error. '$key' given, string expected." + ); + } $this->{$member}[$key] = self::prefixFilePathList( (array) $value, $basePath ); } + break; // Lists of strings case 'dependencies': case 'messages': @@ -209,6 +220,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { // Merge general styles and skin specific styles, retaining media type collation $styles = self::readStyleFiles( $this->styles ); $skinStyles = self::readStyleFiles( self::tryForKey( $this->skinStyles, $context->getSkin(), 'default' ) ); + foreach ( $skinStyles as $media => $style ) { if ( isset( $styles[$media] ) ) { $styles[$media] .= $style; @@ -329,12 +341,14 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { protected static function prefixFilePathList( array $list, $prefix ) { $prefixed = array(); foreach ( $list as $key => $value ) { - if ( is_array( $value ) ) { + if ( is_string( $key ) && is_array( $value ) ) { // array( [path] => array( [options] ) ) $prefixed[$prefix . $key] = $value; - } else { + } else if ( is_int( $key ) && is_string( $value ) ) { // array( [path] ) $prefixed[$key] = $prefix . $value; + } else { + throw new MWException( "Invalid file path list error. '$key' => '$value' given." ); } } return $prefixed;