(bug 4974) Don't follow redirected talk page on "new messages" link
[lhc/web/wiklou.git] / includes / PageHistory.php
index 8280d26..e8a6c07 100644 (file)
@@ -6,9 +6,6 @@
  * @package MediaWiki
  */
 
-/** */
-include_once ( 'SpecialValidate.php' );
-
 define('DIR_PREV', 0);
 define('DIR_NEXT', 1);
 
@@ -28,6 +25,7 @@ class PageHistory {
        var $lastdate;
        var $linesonpage;
        var $mNotificationTimestamp;
+       var $mLatestId = null;
 
        /**
         * Construct a new PageHistory.
@@ -52,8 +50,7 @@ class PageHistory {
         * @returns nothing
         */
        function history() {
-               global $wgUser, $wgOut, $wgLang, $wgShowUpdatedMarker, $wgRequest,
-                       $wgTitle, $wgUseValidation;
+               global $wgUser, $wgOut, $wgRequest, $wgTitle;
 
                /*
                 * Allow client caching.
@@ -169,12 +166,6 @@ class PageHistory {
                $s .= $this->endHistoryList();
                $s .= $navbar;
 
-               /*
-                * Article validation line.
-                */
-               if ($wgUseValidation)
-                       $s .= '<p>' . Validation::getStatisticsLink( $this->mArticle ) . '</p>' ;
-
                $wgOut->addHTML( $s );
                wfProfileOut( $fname );
        }
@@ -186,7 +177,7 @@ class PageHistory {
                $s = wfMsgWikiHtml( 'histlegend' );
                $s .= '<form action="' . $wgTitle->escapeLocalURL( '-' ) . '" method="get">';
                $prefixedkey = htmlspecialchars($wgTitle->getPrefixedDbKey());
-               
+
                // The following line is SUPPOSED to have double-quotes around the
                // $prefixedkey variable, because htmlspecialchars() doesn't escape
                // single-quotes.
@@ -199,7 +190,7 @@ class PageHistory {
                // consideration and cooperation.
                //
                $s .= "<input type='hidden' name='title' value=\"{$prefixedkey}\" />\n";
-               
+
                $s .= $this->submitButton();
                $s .= '<ul id="pagehistory">' . "\n";
                return $s;
@@ -231,7 +222,6 @@ class PageHistory {
 
        /** @todo document */
        function historyLine( $row, $next, $counter = '', $notificationtimestamp = false, $latest = false, $firstInList = false ) {
-               global $wgLang, $wgContLang;
 
                if ( 0 == $row->rev_user ) {
                        $contribsPage =& Title::makeTitle( NS_SPECIAL, 'Contributions' );
@@ -302,8 +292,17 @@ class PageHistory {
        function lastLink( $row, $next, $counter ) {
                global $wgUser;
                $last = htmlspecialchars( wfMsg( 'last' ) );
-               if( is_null( $next )
-                       || ( $row->rev_deleted && !$wgUser->isAllowed( 'undelete' ) ) ) {
+               if( is_null( $next ) ) {
+                       if( $row->rev_timestamp == $this->getEarliestOffset() ) {
+                               return $last;
+                       } else {
+                               // Cut off by paging; there are more behind us...
+                               return $this->mSkin->makeKnownLinkObj(
+                                       $this->mTitle,
+                                       $last,
+                                       "diff={$row->rev_id}&oldid=prev" );
+                       }
+               } elseif( $row->rev_deleted && !$wgUser->isAllowed( 'undelete' ) ) {
                        return $last;
                } else {
                        return $this->mSkin->makeKnownLinkObj(
@@ -384,13 +383,16 @@ class PageHistory {
        }
 
        /** @todo document */
-       function getLatestID( $id = null ) {
-               if ( $id === null) $id = $this->mTitle->getArticleID();
-               $db =& wfGetDB(DB_SLAVE);
-               return $db->selectField( 'revision',
-                       "max(rev_id)",
-                       array( 'rev_page' => $id ),
-                       'PageHistory::getLatestID' );
+       function getLatestId() {
+               if( is_null( $this->mLatestId ) ) {
+                       $id = $this->mTitle->getArticleID();
+                       $db =& wfGetDB(DB_SLAVE);
+                       $this->mLatestId = $db->selectField( 'revision',
+                               "max(rev_id)",
+                               array( 'rev_page' => $id ),
+                               'PageHistory::getLatestID' );
+               }
+               return $this->mLatestId;
        }
 
        /** @todo document */