* Added a proper Pager::doBatchLookups() function
authorAaron Schulz <aaron@users.mediawiki.org>
Thu, 20 Oct 2011 00:43:43 +0000 (00:43 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Thu, 20 Oct 2011 00:43:43 +0000 (00:43 +0000)
* Made HistoryPager use a link batch via Pager::doBatchLookups()

includes/HistoryPage.php
includes/Pager.php

index 8aa7b2b..f4b888f 100644 (file)
@@ -382,6 +382,19 @@ class HistoryPager extends ReverseChronologicalPager {
                return $s;
        }
 
+       function doBatchLookups() {
+               # Do a link batch query
+               $this->mResult->seek( 0 );
+               $batch = new LinkBatch();
+               # Give some pointers to make (last) links
+               foreach ( $this->mResult as $row ) {
+                       $batch->addObj( Title::makeTitleSafe( NS_USER, $row->rev_user_name ) );
+                       $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->rev_user_name ) );
+               }
+               $batch->execute();
+               $this->mResult->seek( 0 );
+       }
+
        /**
         * Creates begin of history list with a submit button
         *
index 99dbd1c..e4c2405 100644 (file)
@@ -325,10 +325,13 @@ abstract class IndexPager extends ContextSource implements Pager {
         *
         * @return String
         */
-       function getBody() {
+       public function getBody() {
                if ( !$this->mQueryDone ) {
                        $this->doQuery();
                }
+               # Do any special query batches before display
+               $this->doBatchLookups();
+               
                # Don't use any extra rows returned by the query
                $numRows = min( $this->mResult->numRows(), $this->mLimit );
 
@@ -384,13 +387,21 @@ abstract class IndexPager extends ContextSource implements Pager {
                );
        }
 
+       /**
+        * Called from getBody(), before getStartBody() is called. This
+        * will be called even if there are no rows in the result set.
+        *
+        * @return void
+        */
+       protected function doBatchLookups() {}
+
        /**
         * Hook into getBody(), allows text to be inserted at the start. This
         * will be called even if there are no rows in the result set.
         *
         * @return String
         */
-       function getStartBody() {
+       protected function getStartBody() {
                return '';
        }
 
@@ -399,7 +410,7 @@ abstract class IndexPager extends ContextSource implements Pager {
         *
         * @return String
         */
-       function getEndBody() {
+       protected function getEndBody() {
                return '';
        }
 
@@ -409,7 +420,7 @@ abstract class IndexPager extends ContextSource implements Pager {
         *
         * @return String
         */
-       function getEmptyBody() {
+       protected function getEmptyBody() {
                return '';
        }