Faster Special:Listusers, should be up to 10x faster for long lists
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 11 Sep 2005 12:33:59 +0000 (12:33 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 11 Sep 2005 12:33:59 +0000 (12:33 +0000)
includes/QueryPage.php
includes/SpecialListusers.php

index b7ff539..4616d59 100644 (file)
@@ -245,6 +245,8 @@ class QueryPage {
                $res = $dbr->query( $sql );
                $num = $dbr->numRows($res);
 
+               $this->preprocessResults( $dbr, $res );
+
                $sk = $wgUser->getSkin( );
 
                if($shownavigation) {
@@ -294,6 +296,11 @@ class QueryPage {
                return $num;
        }
 
+       /**
+        * Do any necessary preprocessing of the result object
+        */
+       function preprocessResults( &$db, &$res ) {}
+
        /**
         * Similar to above, but packaging in a syndicated feed instead of a web page
         */
index 892bbd6..432876e 100644 (file)
@@ -40,14 +40,35 @@ require_once('QueryPage.php');
 class ListUsersPage extends QueryPage {
        var $requestedGroup = '';
        var $requestedUser = '';
-       var $previousResult = null;
-       var $concatGroups = '';
        
        function getName() {
                return 'Listusers';
        }
        function isSyndicated() { return false; }
 
+       /**
+        * Not expensive, this class won't work properly with the caching system anyway
+        */
+       function isExpensive() {
+               return false;
+       }
+
+       /**
+        * Fetch user page links and cache their existence
+        */
+       function preprocessResults( &$db, &$res ) {
+               global $wgLinkCache;
+               
+               $batch = new LinkBatch;
+               while ( $row = $db->fetchObject( $res ) ) {
+                       $batch->addObj( Title::makeTitleSafe( NS_USER, $row->title ) );
+               }
+               $batch->execute( $wgLinkCache );
+
+               // Back to start for display
+               $db->dataSeek( $res, 0 );
+       }
+
        /**
         * Show a drop down list to select a group as well as a user name
         * search box.