(bug 7958) Special:Cite of older version of an article should use old version id.
[lhc/web/wiklou.git] / includes / SkinTemplate.php
index cddd219..1929ff8 100644 (file)
@@ -822,7 +822,6 @@ class SkinTemplate extends Skin {
                global $wgEnableUploads, $wgUploadNavigationUrl;
 
                $action = $wgRequest->getText( 'action' );
-               $oldid = $wgRequest->getVal( 'oldid' );
 
                $nav_urls = array();
                $nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
@@ -852,21 +851,16 @@ class SkinTemplate extends Skin {
                        );
 
                        // Also add a "permalink" while we're at it
-                       if ( (int)$oldid ) {
+                       if ( $this->mRevisionId ) {
                                $nav_urls['permalink'] = array(
                                        'text' => wfMsg( 'permalink' ),
-                                       'href' => ''
+                                       'href' => $wgTitle->getLocalURL( "oldid=$this->mRevisionId" )
                                );
-                       } else {
-                               $revid = $wgArticle ? $wgArticle->getLatest() : 0;
-                               if ( !( $revid == 0 )  )
-                                       $nav_urls['permalink'] = array(
-                                               'text' => wfMsg( 'permalink' ),
-                                               'href' => $wgTitle->getLocalURL( "oldid=$revid" )
-                                       );
                        }
-
-                       wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( &$this, &$nav_urls, &$oldid, &$revid ) );
+                       
+                       // Copy in case this undocumented, shady hook tries to mess with internals
+                       $revid = $this->mRevisionId;
+                       wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( &$this, &$nav_urls, &$revid, &$revid ) );
                }
 
                if( $this->mTitle->getNamespace() != NS_SPECIAL ) {