Merge "UserTest: Cover User::isIP and User::isValidUserName better"
[lhc/web/wiklou.git] / includes / Skin.php
index 84dd3de..177e2b1 100644 (file)
@@ -36,6 +36,12 @@ abstract class Skin extends ContextSource {
        protected $mRelevantTitle = null;
        protected $mRelevantUser = null;
 
+       /**
+        * @var string Stylesheets set to use. Subdirectory in skins/ where various stylesheets are
+        *   located. Only needs to be set if you intend to use the getSkinStylePath() method.
+        */
+       public $stylename = null;
+
        /**
         * Fetch the set of available skins.
         * @return array Associative array of strings
@@ -73,9 +79,19 @@ abstract class Skin extends ContextSource {
                                                // 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' ) ) ) {
+                                                       wfLogWarning(
+                                                               "An old copy of the $aSkin skin was found in your skins/ directory. " .
+                                                               "You should remove it to avoid problems in the future." .
+                                                               "See https://www.mediawiki.org/wiki/Manual:Skin_autodiscovery for details."
+                                                       );
                                                        continue;
                                                }
 
+                                               wfLogWarning(
+                                                       "A skin using autodiscovery mechanism, $aSkin, was found in your skins/ directory. " .
+                                                       "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;
                                        }
                                }
@@ -94,7 +110,6 @@ abstract class Skin extends ContextSource {
        static function getSkinNameMessages() {
                $messages = array();
                foreach ( self::getSkinNames() as $skinKey => $skinName ) {
-                       // Messages: skinname-vector, skinname-monobook
                        $messages[] = "skinname-$skinKey";
                }
                return $messages;
@@ -1082,11 +1097,20 @@ abstract class Skin extends ContextSource {
         * Return a fully resolved style path url to images or styles stored in the current skins's folder.
         * This method returns a url resolved using the configured skin style path
         * and includes the style version inside of the url.
+        *
+        * Requires $stylename to be set, otherwise throws MWException.
+        *
         * @param string $name The name or path of a skin resource file
         * @return string The fully resolved style path url including styleversion
         */
        function getSkinStylePath( $name ) {
                global $wgStylePath, $wgStyleVersion;
+
+               if ( $this->stylename === null ) {
+                       $class = get_class( $this );
+                       throw new MWException( "$class::\$stylename must be set to use getSkinStylePath()" );
+               }
+
                return "$wgStylePath/{$this->stylename}/$name?$wgStyleVersion";
        }