From 25d75b36b0e0bad3d80eb4dcdda0e0548299a021 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 22 Jul 2014 20:25:35 +0200 Subject: [PATCH] Define fallback skin using $wgFallbackSkin instead of hardcoding Vector Bug: 68332 Change-Id: Ibd7485dfa3123fb9ac3e9dd97cbe7129a0969c65 --- includes/DefaultSettings.php | 7 +++++++ includes/Skin.php | 27 ++++++++++++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 3ef59b3435..09f9a6ae73 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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, diff --git a/includes/Skin.php b/includes/Skin.php index e1f0c18c44..fd737c04d2 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -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 ); -- 2.20.1