From: Jeff Janes Date: Fri, 18 Jul 2014 20:21:53 +0000 (-0700) Subject: PostgreSQL: Fix Special:ActiveUsers GROUP BY query X-Git-Tag: 1.31.0-rc.0~12770^2 X-Git-Url: http://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=52328f043c3f3e9a0ce76a8eadb7975bc957846e PostgreSQL: Fix Special:ActiveUsers GROUP BY query For GROUP BY queries, PostgreSQL require all columns in the unaggregated part of the select list to also be in the GROUP BY list. To fix this, add user_name and user_id to the GROUP BY list along side qcc_title. This addition cannot change the query results, because user_name and user_id are functionally dependent on qcc_title: user_name because of the WHERE clause for this query, and user_id due to the 1 to 1 relationship between user_name and user_id enforced by their unique and not null constraints on the underlying table. This has been tested on PostgreSQL and MySQL. Bug: 68087 Change-Id: I3aed715b40ff6e2290220122acbda0f0e74b5b36 --- diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index ff632439b7..0caf6b4a6f 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -115,10 +115,16 @@ class ActiveUsersPager extends UsersPager { ) . ')'; } + if ( $dbr->implicitGroupby() ) { + $options = array( 'GROUP BY' => array( 'qcc_title' ) ); + } else { + $options = array( 'GROUP BY' => array( 'user_name', 'user_id', 'qcc_title' ) ); + } + return array( 'tables' => array( 'querycachetwo', 'user', 'recentchanges' ), 'fields' => array( 'user_name', 'user_id', 'recentedits' => 'COUNT(*)', 'qcc_title' ), - 'options' => array( 'GROUP BY' => array( 'qcc_title' ) ), + 'options' => $options, 'conds' => $conds ); }