http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72481
Revision: 72481
Author: werdna
Date: 2010-09-06 12:11:57 +0000 (Mon, 06 Sep 2010)
Log Message:
-----------
Rewrite User::getSkin, broken in r49493 because requesting the skin for a
particular title had the side-effect of changing the title associated with the
stored Skin object, causing weirdness like the wrong namespace tabs.
Modified Paths:
--------------
trunk/phase3/includes/User.php
Modified: trunk/phase3/includes/User.php
===================================================================
--- trunk/phase3/includes/User.php 2010-09-06 12:09:15 UTC (rev 72480)
+++ trunk/phase3/includes/User.php 2010-09-06 12:11:57 UTC (rev 72481)
@@ -2216,35 +2216,48 @@
* @return Skin The current skin
* @todo FIXME : need to check the old failback system [AV]
*/
- function &getSkin( $t = null ) {
- if ( !isset( $this->mSkin ) ) {
- wfProfileIn( __METHOD__ );
-
- global $wgHiddenPrefs;
- if( !in_array( 'skin', $wgHiddenPrefs ) ) {
- # get the user skin
- global $wgRequest;
- $userSkin = $this->getOption( 'skin' );
- $userSkin = $wgRequest->getVal( 'useskin',
$userSkin );
- } else {
- # if we're not allowing users to override, then
use the default
- global $wgDefaultSkin;
- $userSkin = $wgDefaultSkin;
+ function getSkin( $t = null ) {
+ if ( $t ) {
+ $skin = $this->createSkinObject();
+ $skin->setTitle( $t );
+ return $skin;
+ } else {
+ if ( ! $this->mSkin ) {
+ $this->mSkin = $this->createSkinObject();
}
-
- $this->mSkin = Skin::newFromKey( $userSkin );
- wfProfileOut( __METHOD__ );
- }
- if( $t || !$this->mSkin->getTitle() ) {
- if ( !$t ) {
+
+ if ( ! $this->mSkin->getTitle() ) {
global $wgOut;
$t = $wgOut->getTitle();
+ $this->mSkin->setTitle($t);
}
- $this->mSkin->setTitle( $t );
+
+ return $this->mSkin;
}
- return $this->mSkin;
}
+
+ // Creates a Skin object, for getSkin()
+ private function createSkinObject() {
+ wfProfileIn( __METHOD__ );
+ global $wgHiddenPrefs;
+ if( !in_array( 'skin', $wgHiddenPrefs ) ) {
+ # get the user skin
+ global $wgRequest;
+ $userSkin = $this->getOption( 'skin' );
+ $userSkin = $wgRequest->getVal( 'useskin', $userSkin );
+ } else {
+ # if we're not allowing users to override, then use the
default
+ global $wgDefaultSkin;
+ $userSkin = $wgDefaultSkin;
+ }
+
+ $skin = Skin::newFromKey( $userSkin );
+ wfProfileOut( __METHOD__ );
+
+ return $skin;
+ }
+
/**
* Check the watched status of an article.
* @param $title \type{Title} Title of the article to look at
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs