* Avoid numerous redundant latest-revision lookups in history
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 28 Oct 2005 11:05:32 +0000 (11:05 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 28 Oct 2005 11:05:32 +0000 (11:05 +0000)
RELEASE-NOTES
includes/PageHistory.php

index 2ae0312..65a4d88 100644 (file)
@@ -188,6 +188,8 @@ fully support the editing toolbar, but was found to be too confusing.
 * (bug 3762) Define missing Special:Import UI messages
 * (bug 3771) Handle internal functions in backtrace in wfAbruptExit()
 * (bug 3649) Remove obsolete, broken moveCustomMessages script
+* (bug 3291) 'last' diff link for last history line when not at end
+* Avoid numerous redundant latest-revision lookups in history
 
 
 === Caveats ===
index 8280d26..56c2737 100644 (file)
@@ -28,6 +28,7 @@ class PageHistory {
        var $lastdate;
        var $linesonpage;
        var $mNotificationTimestamp;
+       var $mLatestId = null;
 
        /**
         * Construct a new PageHistory.
@@ -302,8 +303,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 +394,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 */