r49493 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49492‎ | r49493 | r49494 >
Date:04:43, 15 April 2009
Author:demon
Status:deferred (Comments)
Tags:
Comment:
initPage() is far too late to be setting a title, so we'll do it right after newFromKey() is called. Allow getSkin() to be passed a title for context, else fall back to OutputPage's title.
Modified paths:
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -2144,11 +2144,12 @@
21452145 }
21462146
21472147 /**
2148 - * Get the current skin, loading it if required
2149 - * @return \type{Skin} Current skin
 2148+ * Get the current skin, loading it if required, and setting a title
 2149+ * @param Title $t The title to use in the skin
 2150+ * @return Skin The current skin
21502151 * @todo FIXME : need to check the old failback system [AV]
21512152 */
2152 - function &getSkin() {
 2153+ function &getSkin( $t = null ) {
21532154 global $wgRequest, $wgAllowUserSkin, $wgDefaultSkin;
21542155 if ( ! isset( $this->mSkin ) ) {
21552156 wfProfileIn( __METHOD__ );
@@ -2165,6 +2166,11 @@
21662167 $this->mSkin =& Skin::newFromKey( $userSkin );
21672168 wfProfileOut( __METHOD__ );
21682169 }
 2170+ if ( !$t ) {
 2171+ global $wgOut;
 2172+ $t = $wgOut->getTitle();
 2173+ }
 2174+ $this->mSkin->setTitle( $t );
21692175 return $this->mSkin;
21702176 }
21712177
Index: trunk/phase3/includes/Skin.php
@@ -176,8 +176,6 @@
177177
178178 wfProfileIn( __METHOD__ );
179179
180 - $this->mTitle = $out->getTitle();
181 -
182180 # Generally the order of the favicon and apple-touch-icon links
183181 # should not matter, but Konqueror (3.5.9 at least) incorrectly
184182 # uses whichever one appears later in the HTML source. Make sure
@@ -268,12 +266,23 @@
269267 }
270268 }
271269
272 - function setMembers(){
 270+ /**
 271+ * Set some local globals
 272+ */
 273+ protected function setMembers(){
273274 global $wgUser;
274275 $this->mUser = $wgUser;
275276 $this->userpage = $wgUser->getUserPage()->getPrefixedText();
276277 $this->usercss = false;
277278 }
 279+
 280+ /**
 281+ * Set the title
 282+ * @param Title $t The title to use
 283+ */
 284+ public function setTitle( $t ) {
 285+ $this->mTitle = $t;
 286+ }
278287
279288 function outputPage( OutputPage $out ) {
280289 global $wgDebugComments;

Follow-up revisions

RevisionCommit summaryAuthorDate
r49606Fix for r49493: use correct doxygen's @param syntaxialex19:03, 17 April 2009
r49662Followup to r49493: Tweak this so we only set the title if explicitly asking ...demon14:32, 20 April 2009
r72481Rewrite User::getSkin, broken in r49493 because requesting the skin for a par...werdna12:11, 6 September 2010
r75873Cleanup r49493, r72481: Adding skin to $wgHiddenPrefs disabled the useskin pa...demon20:18, 2 November 2010

Comments

#Comment by Werdna (talk | contribs)   12:01, 6 September 2010

This has the annoying side-effect that if you call getSkin() with a title to get a Skin object for another title (for example, to parse the content of another page), it overrides the stored title, which has all sorts of weird effects like changing the tabs.

#Comment by Werdna (talk | contribs)   12:12, 6 September 2010

Fixed in r72481.

Status & tagging log