r45039 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45038‎ | r45039 | r45040 >
Date:19:44, 25 December 2008
Author:pinky
Status:ok (Comments)
Tags:
Comment:
Minor fix to GlobalUserrights: fixed bug where global rights wouldn't show up in special:listusers if the user only had one right because of a change in SpecialListusers.php (r41350)
Modified paths:
  • /trunk/extensions/GlobalUserrights/GlobalUserrights.php (modified) (history)
  • /trunk/extensions/GlobalUserrights/GlobalUserrights_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GlobalUserrights/GlobalUserrights_body.php
@@ -6,7 +6,7 @@
77 * @ingroup Extensions
88 */
99
10 -if( !defined( 'MEDIAWIKI' ) ) die();
 10+if (!defined('MEDIAWIKI')) die();
1111
1212 class GlobalUserrights extends UserrightsPage {
1313
Index: trunk/extensions/GlobalUserrights/GlobalUserrights.php
@@ -10,13 +10,13 @@
1111 * @note Some of the code based on stuff by Lukasz 'TOR' Garczewski, as well as SpecialUserrights.php and CentralAuth
1212 */
1313
14 -if( !defined( 'MEDIAWIKI' ) ) die();
 14+if (!defined('MEDIAWIKI')) die();
1515
1616 // Extension credits
1717 $wgExtensionCredits['specialpage'][] = array(
1818 'name' => 'GlobalUserrights',
1919 'url' => 'http://www.mediawiki.org/wiki/Extension:GlobalUserrights',
20 - 'version' => '1.0',
 20+ 'version' => '1.0.1',
2121 'author' => 'Nathaniel Herman',
2222 'description' => 'Easy [[Special:GlobalUserRights|global user rights]] administration',
2323 'descriptionmsg' => 'gur-desc',
@@ -106,9 +106,9 @@
107107 $dbr = wfGetDB( DB_SLAVE );
108108 list( $gug ) = $dbr->tableNamesN( 'global_user_groups' );
109109 $query['tables'] .= "LEFT JOIN $gug ON user_id=gug_user";
110 - $query['fields'][2] = 'COUNT(ug_group) + COUNT(gug_group) AS numgroups';
 110+ $query['fields'][3] = 'COUNT(ug_group) + COUNT(gug_group) AS numgroups';
111111 // kind of yucky statement, I blame MySQL 5.0.13 http://bugs.mysql.com/bug.php?id=15610
112 - $query['fields'][3] = 'GREATEST(COALESCE(ug_group, gug_group), COALESCE(gug_group, ug_group)) AS singlegroup';
 112+ $query['fields'][4] = 'GREATEST(COALESCE(ug_group, gug_group), COALESCE(gug_group, ug_group)) AS singlegroup';
113113
114114 // if there's a $query['conds']['ug_group'], destroy it and make one that accounts for gug_group
115115 if( isset( $query['conds']['ug_group'] ) ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r41350Make listusers show users' edit counts (bug 15503)aaron15:52, 28 September 2008

Comments

#Comment by Aaron Schulz (talk | contribs)   07:23, 26 December 2008

Isn't there a safer way this could change the fields array?

#Comment by Pinky (talk | contribs)   20:10, 26 December 2008

Well the only other two ways I can think of to do it would be just appending it to the end of the fields array, which should overwrite the original query, making it useless, or something like $query['fields'][] = 'numgroups + COUNT(gug_group) AS numgroups'; which would overwrite the original using the original (not sure if that would work). Neither of those seem like a great option to me, is there something else that's better?

#Comment by Aaron Schulz (talk | contribs)   04:54, 27 December 2008

Hmm, maybe some sort of search and replace?

Status & tagging log