From 126ceb56d7f3f60b5aa04f6709226f1cd07181fe Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Mon, 2 May 2011 15:26:19 +0000 Subject: [PATCH] Get the revision ID from the OutputPage object instead of making a copy --- includes/Skin.php | 34 +++++++++++++++++++++------------- includes/SkinTemplate.php | 8 ++++---- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/includes/Skin.php b/includes/Skin.php index 45fcaa2397..028b403168 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -21,7 +21,6 @@ abstract class Skin { */ var $mWatchLinkNum = 0; // Appended to end of watch link id's /**#@-*/ - protected $mRevisionId; // The revision ID we're looking at, null if not applicable. protected $skinname = 'standard'; protected $mRelevantTitle = null; protected $mRelevantUser = null; @@ -179,7 +178,6 @@ abstract class Skin { function initPage( OutputPage $out ) { wfProfileIn( __METHOD__ ); - $this->mRevisionId = $out->mRevisionId; $this->preloadExistence(); $this->setMembers(); @@ -217,15 +215,6 @@ abstract class Skin { $this->usercss = false; } - /** - * Whether the revision displayed is the latest revision of the page - * - * @return Boolean - */ - public function isRevisionCurrent() { - return $this->mRevisionId == 0 || $this->mRevisionId == $this->getTitle()->getLatestRevID(); - } - /** * Set the RequestContext used in this instance * @@ -264,6 +253,25 @@ abstract class Skin { return $this->getContext()->getUser(); } + /** + * Get the current revision ID + * + * @return Integer + */ + public function getRevisionId() { + return $this->getContext()->getOutput()->getRevisionId(); + } + + /** + * Whether the revision displayed is the latest revision of the page + * + * @return Boolean + */ + public function isRevisionCurrent() { + $revID = $this->getRevisionId(); + return $revID == 0 || $revID == $this->getTitle()->getLatestRevID(); + } + /** * Set the "relevant" title * @see self::getRelevantTitle() @@ -958,7 +966,7 @@ abstract class Skin { */ protected function lastModified( $article ) { if ( !$this->isRevisionCurrent() ) { - $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->mRevisionId ); + $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() ); } else { $timestamp = $article->getTimestamp(); } @@ -1084,7 +1092,7 @@ abstract class Skin { $options = array( 'action' => 'edit' ); if ( !$this->isRevisionCurrent() ) { - $options['oldid'] = intval( $this->mRevisionId ); + $options['oldid'] = intval( $this->getRevisionId() ); } return $options; diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 9b656854f8..18f2990611 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -1186,15 +1186,15 @@ class SkinTemplate extends Skin { } // Also add a "permalink" while we're at it - if ( $this->mRevisionId ) { + $revid = $this->getRevisionId(); + if ( $revid ) { $nav_urls['permalink'] = array( 'text' => wfMsg( 'permalink' ), - 'href' => $out->getTitle()->getLocalURL( "oldid=$this->mRevisionId" ) + 'href' => $out->getTitle()->getLocalURL( "oldid=$revid" ) ); } - // Copy in case this undocumented, shady hook tries to mess with internals - $revid = $this->mRevisionId; + // Use the copy of revision ID in case this undocumented, shady hook tries to mess with internals wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( &$this, &$nav_urls, &$revid, &$revid ) ); } -- 2.20.1