ResourceLoaderImageModule: Improve PHP 5.3 compatibility
authorBartosz Dziewoński <matma.rex@gmail.com>
Sun, 29 Mar 2015 16:29:41 +0000 (18:29 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sun, 29 Mar 2015 16:29:41 +0000 (18:29 +0200)
In PHP 5.3.x and older, the isset() check in code example below will
yield true. In PHP 5.4 and later, and HHVM, it will correctly yield
false. http://3v4l.org/8p3hm

  $options = 'foo';
  isset( $options['bar'] );

Let's not depend on this behavior here.

Change-Id: I67e83af8afe85b3ddfb5db0009759b8ac5bb7d67

includes/resourceloader/ResourceLoaderImageModule.php

index 5be4419..3d65745 100644 (file)
@@ -158,7 +158,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                                        $imageDesc = is_string( $options ) ? $options : $options['image'];
 
                                        $allowedVariants = array_merge(
-                                               isset( $options['variants'] ) ? $options['variants'] : array(),
+                                               is_array( $options ) && isset( $options['variants'] ) ? $options['variants'] : array(),
                                                $this->getGlobalVariants( $type )
                                        );
                                        if ( isset( $this->variants[$type] ) ) {