From: Bryan Davis Date: Thu, 8 Jan 2015 23:24:50 +0000 (-0700) Subject: Guard against unset key access in ResourceLoaderImageModule X-Git-Tag: 1.31.0-rc.0~12736 X-Git-Url: http://git.cyclocoop.org//%22%22._DIR_PLUGIN_FULLCALENDAR.%22prive/themes/spip/images/event_edit.png/%22?a=commitdiff_plain;h=1157312f1e5fe2641784f5c6d0d5ad93dca24f38;p=lhc%2Fweb%2Fwiklou.git Guard against unset key access in ResourceLoaderImageModule Seen in production error logs: Undefined index: icon in ResourceLoaderImageModule.php on line 162 Undefined index: icon in ResourceLoaderImageModule.php on line 185 Change-Id: I44e16563bda2dcc0be3c9694ed2b09d20b3d7468 --- diff --git a/includes/resourceloader/ResourceLoaderImageModule.php b/includes/resourceloader/ResourceLoaderImageModule.php index 9246df729b..67806fffb7 100644 --- a/includes/resourceloader/ResourceLoaderImageModule.php +++ b/includes/resourceloader/ResourceLoaderImageModule.php @@ -158,10 +158,14 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { isset( $options['variants'] ) ? $options['variants'] : array(), $this->getGlobalVariants( $type ) ); - $variantConfig = array_intersect_key( - $this->variants[$type], - array_fill_keys( $allowedVariants, true ) - ); + if ( isset( $this->variants[$type] ) ) { + $variantConfig = array_intersect_key( + $this->variants[$type], + array_fill_keys( $allowedVariants, true ) + ); + } else { + $variantConfig = array(); + } $image = new ResourceLoaderImage( $name, $this->getName(), $imageDesc, $this->localBasePath, $variantConfig ); $this->imageObjects[ $image->getName() ] = $image; @@ -182,9 +186,11 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { if ( !isset( $this->globalVariants[$type] ) ) { $this->globalVariants[$type] = array(); - foreach ( $this->variants[$type] as $name => $config ) { - if ( isset( $config['global'] ) && $config['global'] ) { - $this->globalVariants[$type][] = $name; + if ( isset( $this->variants[$type] ) ) { + foreach ( $this->variants[$type] as $name => $config ) { + if ( isset( $config['global'] ) && $config['global'] ) { + $this->globalVariants[$type][] = $name; + } } } }