From 9e6827d7b56e905521f0110727a46b2d14f31298 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sun, 25 May 2014 23:58:05 +0200 Subject: [PATCH] Don't use autodiscovery for core skins, move them to separate directories MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Step one on the way to killing the autodiscovery mechanism and making the core skins less intertwined with core. This only moves the files and fixes hardcoded paths throughout core. Any further changes will be done in separate patch(es). Moved files: * skins/MonoBook.php → skins/monobook/MonoBook.php * skins/Vector.php → skins/vector/Vector.php Bug: 65748 Change-Id: Ib4bdda5ed3c133fce0113eb17fa39950aa812f87 --- includes/AutoLoader.php | 8 ++++---- includes/Setup.php | 7 +++++++ includes/Skin.php | 14 +++++++++++++- resources/Resources.php | 4 ++-- skins/.gitignore | 2 -- skins/{ => monobook}/MonoBook.php | 0 skins/{ => vector}/Vector.php | 0 7 files changed, 26 insertions(+), 9 deletions(-) rename skins/{ => monobook}/MonoBook.php (100%) rename skins/{ => vector}/Vector.php (100%) diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 05d4c1fde9..e7411a42a3 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -1180,10 +1180,10 @@ $wgAutoloadLocalClasses = array( 'MyLocalSettingsGenerator' => 'mw-config/overrides.php', # skins - 'MonoBookTemplate' => 'skins/MonoBook.php', - 'SkinMonoBook' => 'skins/MonoBook.php', - 'SkinVector' => 'skins/Vector.php', - 'VectorTemplate' => 'skins/Vector.php', + 'MonoBookTemplate' => 'skins/monobook/MonoBook.php', + 'SkinMonoBook' => 'skins/monobook/MonoBook.php', + 'SkinVector' => 'skins/vector/Vector.php', + 'VectorTemplate' => 'skins/vector/Vector.php', ); class AutoLoader { diff --git a/includes/Setup.php b/includes/Setup.php index a1bca22b72..51368b1730 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -601,6 +601,13 @@ $wgTitle = null; $wgDeferredUpdateList = array(); +// Enable default skins. +// This is hacky and bad, but it will go away before 1.24 release (or so I hope). +// These lines should eventually be placed in skins' meta definition files, and loaded by a +// require_once for each skin file generated by the installer and placed in LocalSettings.php. +$wgValidSkinNames['monobook'] = 'MonoBook'; +$wgValidSkinNames['vector'] = 'Vector'; + wfProfileOut( $fname . '-globals' ); wfProfileIn( $fname . '-extensions' ); diff --git a/includes/Skin.php b/includes/Skin.php index 06f39b1fc3..84dd3de09f 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -63,6 +63,19 @@ abstract class Skin extends ContextSource { if ( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) { $aSkin = $matches[1]; + + // Explicitly disallow loading core skins via the autodiscovery mechanism. + // + // They should be loaded already (in a non-autodicovery way), but old files might still + // exist on the server because our MW version upgrade process is widely documented as + // requiring just copying over all files, without removing old ones. + // + // This is one of the reasons we should have never used autodiscovery in the first + // place. This hack can be safely removed when autodiscovery is gone. + if ( in_array( $aSkin, array( 'CologneBlue', 'Modern', 'MonoBook', 'Vector' ) ) ) { + continue; + } + $wgValidSkinNames[strtolower( $aSkin )] = $aSkin; } } @@ -184,7 +197,6 @@ abstract class Skin extends ContextSource { # is no longer valid. wfDebug( "Skin class does not exist: $className\n" ); $className = 'SkinVector'; - require_once "{$wgStyleDirectory}/Vector.php"; } } $skin = new $className( $key ); diff --git a/resources/Resources.php b/resources/Resources.php index d7df027c0c..6926d13730 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1227,7 +1227,7 @@ return array( 'scripts' => 'resources/src/mediawiki.special/mediawiki.special.js', 'styles' => 'resources/src/mediawiki.special/mediawiki.special.css', 'skinStyles' => array( - 'vector' => 'skins/vector/special.less', + 'vector' => 'skins/vector/special.less', // FIXME this should use $wgStyleDirectory ), ), 'mediawiki.special.block' => array( @@ -1276,7 +1276,7 @@ return array( 'styles' => 'resources/src/mediawiki.special/mediawiki.special.preferences.css', 'position' => 'top', 'skinStyles' => array( - 'vector' => 'skins/vector/special.preferences.less', + 'vector' => 'skins/vector/special.preferences.less', // FIXME this should use $wgStyleDirectory ), 'messages' => array( 'prefs-tabs-navigation-hint', diff --git a/skins/.gitignore b/skins/.gitignore index 3ab8af25b8..a35670e8d3 100644 --- a/skins/.gitignore +++ b/skins/.gitignore @@ -7,5 +7,3 @@ !vector/* *.php -!MonoBook.php -!Vector.php diff --git a/skins/MonoBook.php b/skins/monobook/MonoBook.php similarity index 100% rename from skins/MonoBook.php rename to skins/monobook/MonoBook.php diff --git a/skins/Vector.php b/skins/vector/Vector.php similarity index 100% rename from skins/Vector.php rename to skins/vector/Vector.php -- 2.20.1