Define fallback skin using $wgFallbackSkin instead of hardcoding Vector
authorBartosz Dziewoński <matma.rex@gmail.com>
Tue, 22 Jul 2014 18:25:35 +0000 (20:25 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sun, 27 Jul 2014 20:42:24 +0000 (22:42 +0200)
Bug: 68332
Change-Id: Ibd7485dfa3123fb9ac3e9dd97cbe7129a0969c65

includes/DefaultSettings.php
includes/Skin.php

index 3ef59b3..09f9a6a 100644 (file)
@@ -2963,6 +2963,13 @@ $wgValidateAllHtml = false;
  */
 $wgDefaultSkin = 'vector';
 
+/**
+ * Fallback skin used when the skin defined by $wgDefaultSkin can't be found.
+ *
+ * @since 1.24
+ */
+$wgFallbackSkin = 'vector';
+
 /**
  * Specify the names of skins that should not be presented in the list of
  * available skins in user preferences. If you want to remove a skin entirely,
index e1f0c18..fd737c0 100644 (file)
@@ -145,25 +145,28 @@ abstract class Skin extends ContextSource {
 
        /**
         * Normalize a skin preference value to a form that can be loaded.
-        * If a skin can't be found, it will fall back to the configured
-        * default, or the hardcoded default if that's broken.
+        *
+        * If a skin can't be found, it will fall back to the configured default ($wgDefaultSkin), or the
+        * hardcoded default ($wgFallbackSkin) if the default skin is unavailable too.
+        *
         * @param string $key 'monobook', 'vector', etc.
         * @return string
         */
        static function normalizeKey( $key ) {
-               global $wgDefaultSkin;
+               global $wgDefaultSkin, $wgFallbackSkin;
 
                $skinNames = Skin::getSkinNames();
 
                // Make keys lowercase for case-insensitive matching.
                $skinNames = array_change_key_case( $skinNames, CASE_LOWER );
                $key = strtolower( $key );
-               $default = strtolower( $wgDefaultSkin );
+               $defaultSkin = strtolower( $wgDefaultSkin );
+               $fallbackSkin = strtolower( $wgFallbackSkin );
 
                if ( $key == '' || $key == 'default' ) {
                        // Don't return the default immediately;
                        // in a misconfiguration we need to fall back.
-                       $key = $default;
+                       $key = $defaultSkin;
                }
 
                if ( isset( $skinNames[$key] ) ) {
@@ -173,7 +176,7 @@ abstract class Skin extends ContextSource {
                // Older versions of the software used a numeric setting
                // in the user preferences.
                $fallback = array(
-                       0 => $default,
+                       0 => $defaultSkin,
                        2 => 'cologneblue'
                );
 
@@ -183,10 +186,10 @@ abstract class Skin extends ContextSource {
 
                if ( isset( $skinNames[$key] ) ) {
                        return $key;
-               } elseif ( isset( $skinNames[$default] ) ) {
-                       return $default;
+               } elseif ( isset( $skinNames[$defaultSkin] ) ) {
+                       return $defaultSkin;
                } else {
-                       return 'vector';
+                       return $fallbackSkin;
                }
        }
 
@@ -196,7 +199,7 @@ abstract class Skin extends ContextSource {
         * @return Skin
         */
        static function &newFromKey( $key ) {
-               global $wgStyleDirectory;
+               global $wgStyleDirectory, $wgFallbackSkin;
 
                $key = Skin::normalizeKey( $key );
 
@@ -216,7 +219,9 @@ abstract class Skin extends ContextSource {
                                # except by SQL manipulation if a previously valid skin name
                                # is no longer valid.
                                wfDebug( "Skin class does not exist: $className\n" );
-                               $className = 'SkinVector';
+
+                               $fallback = $skinNames[ Skin::normalizeKey( $wgFallbackSkin ) ];
+                               $className = "Skin{$fallback}";
                        }
                }
                $skin = new $className( $key );