From c7eebf66b193d1a46f0d808131d0d1774a6527e2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 3 Oct 2004 10:42:02 +0000 Subject: [PATCH] ShortPages and LongPages are almsot identical; remove some duplication. --- includes/SpecialLongpages.php | 28 ++++------------------------ includes/SpecialShortpages.php | 3 ++- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/includes/SpecialLongpages.php b/includes/SpecialLongpages.php index 93e55e54bf..75f6e5c6e6 100644 --- a/includes/SpecialLongpages.php +++ b/includes/SpecialLongpages.php @@ -8,42 +8,22 @@ /** * */ -require_once( "QueryPage.php" ); +require_once( 'SpecialShortpages.php' ); /** * * @package MediaWiki * @subpackage SpecialPage */ -class LongPagesPage extends QueryPage { +class LongPagesPage extends ShortPagesPage { function getName() { return "Longpages"; } - function isExpensive() { + function sortDescending() { return true; } - - function getSQL() { - $dbr =& wfGetDB( DB_SLAVE ); - $cur = $dbr->tableName( 'cur' ); - - return - "SELECT 'Longpages' as type, - cur_namespace as namespace, - cur_title as title, - LENGTH(cur_text) AS value - FROM $cur - WHERE cur_namespace=0 AND cur_is_redirect=0"; - } - - function formatResult( $skin, $result ) { - global $wgLang; - $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->value ) ); - $link = $skin->makeKnownLink( $result->title, "" ); - return "{$link} ({$nb})"; - } } /** @@ -53,7 +33,7 @@ function wfSpecialLongpages() { list( $limit, $offset ) = wfCheckLimits(); - $lpp = new LongPagesPage( ); + $lpp = new LongPagesPage(); $lpp->doQuery( $offset, $limit ); } diff --git a/includes/SpecialShortpages.php b/includes/SpecialShortpages.php index 3aeaa4f5d6..01fe45f8d7 100644 --- a/includes/SpecialShortpages.php +++ b/includes/SpecialShortpages.php @@ -29,9 +29,10 @@ class ShortPagesPage extends QueryPage { function getSQL() { $dbr =& wfGetDB( DB_SLAVE ); $cur = $dbr->tableName( 'cur' ); + $name = $dbr->addQuotes( $this->getName() ); return - "SELECT 'Shortpages' as type, + "SELECT $name as type, cur_namespace as namespace, cur_title as title, LENGTH(cur_text) AS value -- 2.20.1