r23210 MediaWiki - Code Review archive

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

Diff [purge]

Index: trunk/extensions/Contributors/Contributors.page.php
@@ -147,7 +147,13 @@
148148 $dbr =& wfGetDB( DB_SLAVE );
149149 $rev = $dbr->tableName( 'revision' );
150150 $aid = $this->target->getArticleId();
151 - $res = $dbr->query( "SELECT COUNT(*) AS count, rev_user, rev_user_text FROM {$rev} WHERE rev_page = {$aid} GROUP BY rev_user_text ORDER BY count DESC", __METHOD__ );
 151+ $sql = "SELECT COUNT(*) AS count, rev_user, rev_user_text FROM {$rev} WHERE rev_page = {$aid}";
 152+ $groupby = "GROUP BY rev_user_text";
 153+ if( !$dbr->implicitGroupby() )
 154+ $groupby .= ",rev_user";
 155+ $orderby = "ORDER BY count DESC";
 156+ $sql .= " $groupby $orderby";
 157+ $res = $dbr->query( $sql, __METHOD__ );
152158 if( $res && $dbr->numRows( $res ) > 0 ) {
153159 while( $row = $dbr->fetchObject( $res ) )
154160 $contributors[ $row->rev_user_text ] = array( $row->rev_user, $row->count );

Status & tagging log