r23209 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23208‎ | r23209 | r23210 >
Date:11:22, 22 June 2007
Author:greg
Status:old
Tags:
Comment:
Fix GROUP BY for non-implicitGroupby databases
Modified paths:
  • /trunk/extensions/CountEdits/CountEdits.page.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CountEdits/CountEdits.page.php
@@ -92,7 +92,12 @@
9393 global $wgUser, $wgLang;
9494 $dbr =& wfGetDB( DB_SLAVE );
9595 $rev = $dbr->tableName( 'revision' );
96 - $sql = "SELECT COUNT(*) AS count, rev_user, rev_user_text FROM $rev GROUP BY rev_user_text ORDER BY count DESC LIMIT 0,11";
 96+ $sql = "SELECT COUNT(*) AS count, rev_user, rev_user_text FROM $rev";
 97+ $groupby = "GROUP BY rev_user_text";
 98+ if( !$dbr->implicitGroupby() )
 99+ $groupby .= ", rev_user";
 100+ $orderby = "ORDER BY count DESC LIMIT 11";
 101+ $sql .= " $groupby $orderby";
97102 $res = $dbr->query( $sql );
98103 if( $res && $dbr->numRows( $res ) > 0 ) {
99104 $skin = $wgUser->getSkin();

Status & tagging log