Record and report memory usage change in profiling.
[lhc/web/wiklou.git] / includes / SpecialShortpages.php
index c74158f..4feb514 100644 (file)
@@ -1,37 +1,52 @@
-<?
+<?php
+#
+# SpecialShortpages extends QueryPage. It is used to return the shortest
+# pages in the database.
+#
 
-include_once("QueryPage.php");
+require_once("QueryPage.php");
 
 class ShortPagesPage extends QueryPage {
-    
-    function getName() {
-       return "Shortpages";
-    }
-    
-    function isExpensive() {
-       return 1;
-    }
-    
-    function getSQL( $offset, $limit ) {
-       return "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " .
-         "WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
-         "LENGTH(cur_text) LIMIT {$offset}, {$limit}";
-    }
-    
-    function formatResult( $skin, $result ) {
-       $nb = wfMsg( "nbytes", $result->len );
-       $link = $skin->makeKnownLink( $result->cur_title, "" );
-       return "{$link} ({$nb})";
-    }
+
+       function getName() {
+               return "Shortpages";
+       }
+
+       function isExpensive() {
+               return true;
+       }
+
+       function getSQL() {
+               $dbr =& wfGetDB( DB_SLAVE );
+               $cur = $dbr->tableName( 'cur' );
+               
+               return
+                       "SELECT 'Shortpages' 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 sortDescending() {
+               return false;
+       }
+
+       function formatResult( $skin, $result ) {
+               global $wgLang;
+               $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->value ) );
+               $link = $skin->makeKnownLink( $result->title, "" );
+               return "{$link} ({$nb})";
+       }
 }
 
-function wfSpecialShortpages()
-{
-    list( $limit, $offset ) = wfCheckLimits();
-    
-    $spp = new ShortPagesPage();
-    
-    return $spp->doQuery( $offset, $limit );
+function wfSpecialShortpages() {
+       list( $limit, $offset ) = wfCheckLimits();
+
+       $spp = new ShortPagesPage();
+
+       return $spp->doQuery( $offset, $limit );
 }
 
 ?>