Withoutaname has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/148663

Change subject: Substituted and removed loadModes() from ImageGalleryBase.php
......................................................................

Substituted and removed loadModes() from ImageGalleryBase.php

Also made local the static private variable $modeMapping and passed
it by reference as an array member argument into wfRunHooks so as to allow
direct modification of the variable.

Change-Id: I591cc4c222c601e9361c86e54402620f24b43af6
---
M includes/gallery/ImageGalleryBase.php
1 file changed, 17 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/63/148663/1

diff --git a/includes/gallery/ImageGalleryBase.php 
b/includes/gallery/ImageGalleryBase.php
index 837a731..0366d23 100644
--- a/includes/gallery/ImageGalleryBase.php
+++ b/includes/gallery/ImageGalleryBase.php
@@ -78,9 +78,6 @@
        /** @var array */
        protected $mAttribs = array();
 
-       /** @var bool */
-       static private $modeMapping = false;
-
        /**
         * Get a new image gallery. This is the method other callers
         * should use to get a gallery.
@@ -88,25 +85,12 @@
         * @param string|bool $mode Mode to use. False to use the default
         * @throws MWException
         */
-       static function factory( $mode = false ) {
+       public static function factory( $mode = false ) {
                global $wgGalleryOptions, $wgContLang;
-               self::loadModes();
-               if ( !$mode ) {
-                       $mode = $wgGalleryOptions['mode'];
-               }
 
-               $mode = $wgContLang->lc( $mode );
-
-               if ( isset( self::$modeMapping[$mode] ) ) {
-                       return new self::$modeMapping[$mode]( $mode );
-               } else {
-                       throw new MWException( "No gallery class registered for 
mode $mode" );
-               }
-       }
-
-       private static function loadModes() {
-               if ( self::$modeMapping === false ) {
-                       self::$modeMapping = array(
+               static $modeMapping = false;
+               if ( $modeMapping === false ) {
+                       $modeMapping = array(
                                'traditional' => 'TraditionalImageGallery',
                                'nolines' => 'NolinesImageGallery',
                                'packed' => 'PackedImageGallery',
@@ -114,7 +98,19 @@
                                'packed-overlay' => 'PackedOverlayImageGallery',
                        );
                        // Allow extensions to make a new gallery format.
-                       wfRunHooks( 'GalleryGetModes', self::$modeMapping );
+                       wfRunHooks( 'GalleryGetModes', array( &$modeMapping ) );
+               }
+
+               if ( !$mode ) {
+                       $mode = $wgGalleryOptions['mode'];
+               }
+
+               $mode = $wgContLang->lc( $mode );
+
+               if ( isset( $modeMapping[$mode] ) ) {
+                       return new $modeMapping[$mode]( $mode );
+               } else {
+                       throw new MWException( "No gallery class registered for 
mode $mode" );
                }
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/148663
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I591cc4c222c601e9361c86e54402620f24b43af6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Withoutaname <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to