From: Rob Church Date: Wed, 22 Aug 2007 08:05:40 +0000 (+0000) Subject: * (bug 9026) Incorrect heading numbering when viewing Special:Statistics with "auto... X-Git-Tag: 1.31.0-rc.0~51699 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=f63de71c59479ea0800e1832bfc10a6d3f5565f2;p=lhc%2Fweb%2Fwiklou.git * (bug 9026) Incorrect heading numbering when viewing Special:Statistics with "auto-numbered headings" enabled * Some minor cleanup and bits of refactoring --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index c30791fb33..8cfb5b69ba 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -398,6 +398,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN in the wrong order * (bug 10985) Special:DoubleRedirects was omitting "fixed" results when cached, leading to inconsistent paging behaviour +* (bug 9026) Incorrect heading numbering when viewing Special:Statistics with + "auto-numbered headings" enabled == API changes since 1.10 == diff --git a/includes/SpecialStatistics.php b/includes/SpecialStatistics.php index 6343edd13f..a2fd64537e 100644 --- a/includes/SpecialStatistics.php +++ b/includes/SpecialStatistics.php @@ -1,18 +1,17 @@ getVal( 'action' ); - $dbr = wfGetDB( DB_SLAVE ); $views = SiteStats::views(); @@ -24,14 +23,14 @@ function wfSpecialStatistics() { $admins = SiteStats::admins(); $numJobs = SiteStats::jobs(); - if ($action == 'raw') { + if( $wgRequest->getVal( 'action' ) == 'raw' ) { $wgOut->disable(); header( 'Pragma: nocache' ); echo "total=$total;good=$good;views=$views;edits=$edits;users=$users;admins=$admins;images=$images;jobs=$numJobs\n"; return; } else { - $text = '==' . wfMsg( 'sitestats' ) . "==\n" ; - $text .= wfMsgExt( 'sitestatstext', array ( 'parsemag' ), + $text = '==' . wfMsg( 'sitestats' ) . "==\n"; + $text .= wfMsgExt( 'sitestatstext', array( 'parsemag' ), $wgLang->formatNum( $total ), $wgLang->formatNum( $good ), $wgLang->formatNum( $views ), @@ -43,7 +42,6 @@ function wfSpecialStatistics() { ); $text .= "\n==" . wfMsg( 'userstats' ) . "==\n"; - $text .= wfMsgExt( 'userstatstext', array ( 'parsemag' ), $wgLang->formatNum( $users ), $wgLang->formatNum( $admins ), @@ -52,32 +50,41 @@ function wfSpecialStatistics() { User::makeGroupLinkWiki( 'sysop' ) ); - $wgOut->addWikiText( $text ); - global $wgDisableCounters, $wgMiserMode, $wgUser, $wgLang, $wgContLang; if( !$wgDisableCounters && !$wgMiserMode ) { - $page = $dbr->tableName( 'page' ); - $sql = "SELECT page_namespace, page_title, page_counter FROM {$page} WHERE page_is_redirect = 0 AND page_counter > 0 ORDER BY page_counter DESC"; - $sql = $dbr->limitResult($sql, 10, 0); - $res = $dbr->query( $sql, $fname ); - if( $res ) { - $wgOut->addHtml( '

' . wfMsgHtml( 'statistics-mostpopular' ) . '

' ); - $skin = $wgUser->getSkin(); - $wgOut->addHtml( '
    ' ); - while( $row = $dbr->fetchObject( $res ) ) { - $link = $skin->makeKnownLinkObj( Title::makeTitleSafe( $row->page_namespace, $row->page_title ) ); - $dirmark = $wgContLang->getDirMark(); - $wgOut->addHtml( '
  1. ' . $link . $dirmark . ' [' . $wgLang->formatNum( $row->page_counter ) . ']
  2. ' ); + $res = $dbr->select( + 'page', + array( + 'page_namespace', + 'page_title', + 'page_counter', + ), + array( + 'page_is_redirect' => 0, + 'page_counter > 0', + ), + __METHOD__, + array( + 'ORDER BY' => 'page_counter DESC', + 'LIMIT' => 10, + ) + ); + if( $res->numRows() > 0 ) { + $text .= '==' . wfMsg( 'statistics-mostpopular' ) . "==\n"; + while( $row = $res->fetchObject() ) { + $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); + if( $title instanceof Title ) + $text .= '* [[' . $title->getPrefixedText() . ']] (' . $wgLang->formatNum( $row->page_counter ) . ")\n"; } - $wgOut->addHtml( '
' ); - $dbr->freeResult( $res ); + $res->free(); } } $footer = wfMsg( 'statistics-footer' ); if( !wfEmptyMsg( 'statistics-footer', $footer ) && $footer != '' ) - $wgOut->addWikiText( $footer ); - + $text .= $footer; + + $wgOut->addWikiText( $text ); } -} - + +} \ No newline at end of file