Get the revision ID from the OutputPage object instead of making a copy
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Mon, 2 May 2011 15:26:19 +0000 (15:26 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Mon, 2 May 2011 15:26:19 +0000 (15:26 +0000)
includes/Skin.php
includes/SkinTemplate.php

index 45fcaa2..028b403 100644 (file)
@@ -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;
index 9b65685..18f2990 100644 (file)
@@ -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 ) );
                }