r25039 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25038‎ | r25039 | r25040 >
Date:08:05, 22 August 2007
Author:robchurch
Status:old
Tags:
Comment:
* (bug 9026) Incorrect heading numbering when viewing Special:Statistics with "auto-numbered headings" enabled
* Some minor cleanup and bits of refactoring
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialStatistics.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialStatistics.php
@@ -1,18 +1,17 @@
22 <?php
 3+
34 /**
4 -*
5 -* @addtogroup SpecialPage
6 -*/
 5+ *
 6+ * @addtogroup SpecialPage
 7+ */
78
89 /**
9 -* constructor
10 -*/
11 -function wfSpecialStatistics() {
 10+ * Show the special page
 11+ *
 12+ * @param mixed $par (not used)
 13+ */
 14+function wfSpecialStatistics( $par = '' ) {
1215 global $wgOut, $wgLang, $wgRequest;
13 - $fname = 'wfSpecialStatistics';
14 -
15 - $action = $wgRequest->getVal( 'action' );
16 -
1716 $dbr = wfGetDB( DB_SLAVE );
1817
1918 $views = SiteStats::views();
@@ -24,14 +23,14 @@
2524 $admins = SiteStats::admins();
2625 $numJobs = SiteStats::jobs();
2726
28 - if ($action == 'raw') {
 27+ if( $wgRequest->getVal( 'action' ) == 'raw' ) {
2928 $wgOut->disable();
3029 header( 'Pragma: nocache' );
3130 echo "total=$total;good=$good;views=$views;edits=$edits;users=$users;admins=$admins;images=$images;jobs=$numJobs\n";
3231 return;
3332 } else {
34 - $text = '==' . wfMsg( 'sitestats' ) . "==\n" ;
35 - $text .= wfMsgExt( 'sitestatstext', array ( 'parsemag' ),
 33+ $text = '==' . wfMsg( 'sitestats' ) . "==\n";
 34+ $text .= wfMsgExt( 'sitestatstext', array( 'parsemag' ),
3635 $wgLang->formatNum( $total ),
3736 $wgLang->formatNum( $good ),
3837 $wgLang->formatNum( $views ),
@@ -43,7 +42,6 @@
4443 );
4544
4645 $text .= "\n==" . wfMsg( 'userstats' ) . "==\n";
47 -
4846 $text .= wfMsgExt( 'userstatstext', array ( 'parsemag' ),
4947 $wgLang->formatNum( $users ),
5048 $wgLang->formatNum( $admins ),
@@ -52,32 +50,41 @@
5351 User::makeGroupLinkWiki( 'sysop' )
5452 );
5553
56 - $wgOut->addWikiText( $text );
57 -
5854 global $wgDisableCounters, $wgMiserMode, $wgUser, $wgLang, $wgContLang;
5955 if( !$wgDisableCounters && !$wgMiserMode ) {
60 - $page = $dbr->tableName( 'page' );
61 - $sql = "SELECT page_namespace, page_title, page_counter FROM {$page} WHERE page_is_redirect = 0 AND page_counter > 0 ORDER BY page_counter DESC";
62 - $sql = $dbr->limitResult($sql, 10, 0);
63 - $res = $dbr->query( $sql, $fname );
64 - if( $res ) {
65 - $wgOut->addHtml( '<h2>' . wfMsgHtml( 'statistics-mostpopular' ) . '</h2>' );
66 - $skin = $wgUser->getSkin();
67 - $wgOut->addHtml( '<ol>' );
68 - while( $row = $dbr->fetchObject( $res ) ) {
69 - $link = $skin->makeKnownLinkObj( Title::makeTitleSafe( $row->page_namespace, $row->page_title ) );
70 - $dirmark = $wgContLang->getDirMark();
71 - $wgOut->addHtml( '<li>' . $link . $dirmark . ' [' . $wgLang->formatNum( $row->page_counter ) . ']</li>' );
 56+ $res = $dbr->select(
 57+ 'page',
 58+ array(
 59+ 'page_namespace',
 60+ 'page_title',
 61+ 'page_counter',
 62+ ),
 63+ array(
 64+ 'page_is_redirect' => 0,
 65+ 'page_counter > 0',
 66+ ),
 67+ __METHOD__,
 68+ array(
 69+ 'ORDER BY' => 'page_counter DESC',
 70+ 'LIMIT' => 10,
 71+ )
 72+ );
 73+ if( $res->numRows() > 0 ) {
 74+ $text .= '==' . wfMsg( 'statistics-mostpopular' ) . "==\n";
 75+ while( $row = $res->fetchObject() ) {
 76+ $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
 77+ if( $title instanceof Title )
 78+ $text .= '* [[' . $title->getPrefixedText() . ']] (' . $wgLang->formatNum( $row->page_counter ) . ")\n";
7279 }
73 - $wgOut->addHtml( '</ol>' );
74 - $dbr->freeResult( $res );
 80+ $res->free();
7581 }
7682 }
7783
7884 $footer = wfMsg( 'statistics-footer' );
7985 if( !wfEmptyMsg( 'statistics-footer', $footer ) && $footer != '' )
80 - $wgOut->addWikiText( $footer );
81 -
 86+ $text .= $footer;
 87+
 88+ $wgOut->addWikiText( $text );
8289 }
83 -}
84 -
 90+
 91+}
\ No newline at end of file
Index: trunk/phase3/RELEASE-NOTES
@@ -398,6 +398,8 @@
399399 in the wrong order
400400 * (bug 10985) Special:DoubleRedirects was omitting "fixed" results when cached,
401401 leading to inconsistent paging behaviour
 402+* (bug 9026) Incorrect heading numbering when viewing Special:Statistics with
 403+ "auto-numbered headings" enabled
402404
403405 == API changes since 1.10 ==
404406

Follow-up revisions

RevisionCommit summaryAuthorDate
r25109Merged revisions 25016-25108 via svnmerge from...david07:30, 24 August 2007

Status & tagging log