Record and report memory usage change in profiling.
[lhc/web/wiklou.git] / includes / SpecialShortpages.php
index 2cb6c37..4feb514 100644 (file)
@@ -1,6 +1,10 @@
 <?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 {
 
@@ -9,24 +13,35 @@ class ShortPagesPage extends QueryPage {
        }
 
        function isExpensive() {
-               return 1;
+               return true;
        }
 
-       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 len " .
-                 "LIMIT {$offset}, {$limit}";
+       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 ) {
-               $nb = wfMsg( "nbytes", $result->len );
-               $link = $skin->makeKnownLink( $result->cur_title, "" );
+               global $wgLang;
+               $nb = wfMsg( "nbytes", $wgLang->formatNum( $result->value ) );
+               $link = $skin->makeKnownLink( $result->title, "" );
                return "{$link} ({$nb})";
        }
 }
 
-function wfSpecialShortpages()
-{
+function wfSpecialShortpages() {
        list( $limit, $offset ) = wfCheckLimits();
 
        $spp = new ShortPagesPage();