From: Andrew Garrett Date: Mon, 6 Sep 2010 12:11:57 +0000 (+0000) Subject: Rewrite User::getSkin, broken in r49493 because requesting the skin for a particular... X-Git-Tag: 1.31.0-rc.0~35125 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=99357479ea14670d5f0499b3fdf805a1edad70a5;p=lhc%2Fweb%2Fwiklou.git 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. --- diff --git a/includes/User.php b/includes/User.php index eee0684bab..ef52e70f2f 100644 --- a/includes/User.php +++ b/includes/User.php @@ -2216,33 +2216,46 @@ class User { * @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; } /**