r75177 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75176‎ | r75177 | r75178 >
Date:22:34, 21 October 2010
Author:tparscal
Status:ok
Tags:
Comment:
Fixed missing break; in ResourceLoaderFileModule::__construct, and added extra error checking to it's input arrays.
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php
@@ -139,9 +139,20 @@
140140 case 'languageScripts':
141141 case 'skinScripts':
142142 case 'skinStyles':
143 - foreach ( (array) $option as $key => $value ) {
 143+ if ( !is_array( $option ) ) {
 144+ throw new MWException(
 145+ "Invalid collated file path list error. '$option' given, array expected."
 146+ );
 147+ }
 148+ foreach ( $option as $key => $value ) {
 149+ if ( !is_string( $key ) ) {
 150+ throw new MWException(
 151+ "Invalid collated file path list key error. '$key' given, string expected."
 152+ );
 153+ }
144154 $this->{$member}[$key] = self::prefixFilePathList( (array) $value, $basePath );
145155 }
 156+ break;
146157 // Lists of strings
147158 case 'dependencies':
148159 case 'messages':
@@ -209,6 +220,7 @@
210221 // Merge general styles and skin specific styles, retaining media type collation
211222 $styles = self::readStyleFiles( $this->styles );
212223 $skinStyles = self::readStyleFiles( self::tryForKey( $this->skinStyles, $context->getSkin(), 'default' ) );
 224+
213225 foreach ( $skinStyles as $media => $style ) {
214226 if ( isset( $styles[$media] ) ) {
215227 $styles[$media] .= $style;
@@ -329,12 +341,14 @@
330342 protected static function prefixFilePathList( array $list, $prefix ) {
331343 $prefixed = array();
332344 foreach ( $list as $key => $value ) {
333 - if ( is_array( $value ) ) {
 345+ if ( is_string( $key ) && is_array( $value ) ) {
334346 // array( [path] => array( [options] ) )
335347 $prefixed[$prefix . $key] = $value;
336 - } else {
 348+ } else if ( is_int( $key ) && is_string( $value ) ) {
337349 // array( [path] )
338350 $prefixed[$key] = $prefix . $value;
 351+ } else {
 352+ throw new MWException( "Invalid file path list error. '$key' => '$value' given." );
339353 }
340354 }
341355 return $prefixed;

Status & tagging log