$wgSkipSkins[] = $wgSkipSkin;
}
-// Register a hidden "fallback" skin
-$wgValidSkinNames['fallback'] = 'Fallback'; // SkinFallback
+// Register skins
+// Use a closure to avoid leaking into global state
+call_user_func( function() use ( $wgValidSkinNames ) {
+ $factory = SkinFactory::getDefaultInstance();
+ foreach ( $wgValidSkinNames as $name => $skin ) {
+ $factory->register( $name, $skin, function() use ( $skin ) {
+ $class = "Skin$skin";
+ return new $class;
+ } );
+ }
+ // Register a hidden "fallback" skin
+ $factory->register( 'fallback', 'Fallback', function() {
+ return new SkinFallback;
+ } );
+} );
$wgSkipSkins[] = 'fallback';
if ( $wgLocalInterwiki ) {
*/
private $displayNames = array();
+ /**
+ * Map of name => class name without "Skin" prefix
+ * for legacy skins using the autoloader
+ * @var array
+ */
+ private $legacySkins = array();
+
/**
* @var SkinFactory
*/
* @return array
*/
private function getLegacySkinNames() {
- global $wgValidSkinNames;
static $skinsInitialised = false;
- if ( !$skinsInitialised || !count( $wgValidSkinNames ) ) {
+ if ( !$skinsInitialised || !count( $this->legacySkins ) ) {
# Get a list of available skins
# Build using the regular expression '^(.*).php$'
# Array keys are all lower case, array value keep the case used by filename
"The mechanism will be removed in MediaWiki 1.25 and the skin will no longer be recognized. " .
"See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for information how to fix this."
);
- $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
+ $this->legacySkins[strtolower( $aSkin )] = $aSkin;
}
}
$skinDir->close();
$skinsInitialised = true;
wfProfileOut( __METHOD__ . '-init' );
}
- return $wgValidSkinNames;
+ return $this->legacySkins;
}
protected function setUp() {
parent::setUp();
- $this->setMwGlobals( array(
- 'wgValidSkinNames' => array( 'vector' => 'Vector' ),
- ) );
+ // The return value of the closure shouldn't matter since this test should
+ // never call it
+ SkinFactory::getDefaultInstance()->register( 'vector', 'Vector', function(){});
}
/**