From 117ed3d83ee434292388b233b528085428903e13 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 11 Sep 2005 12:33:59 +0000 Subject: [PATCH] Faster Special:Listusers, should be up to 10x faster for long lists --- includes/QueryPage.php | 7 +++++++ includes/SpecialListusers.php | 25 +++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/includes/QueryPage.php b/includes/QueryPage.php index b7ff539853..4616d592b5 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -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 */ diff --git a/includes/SpecialListusers.php b/includes/SpecialListusers.php index 892bbd6ace..432876e1e9 100644 --- a/includes/SpecialListusers.php +++ b/includes/SpecialListusers.php @@ -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. -- 2.20.1