r34500 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34499‎ | r34500 | r34501 >
Date:10:00, 9 May 2008
Author:catrope
Status:old
Tags:
Comment:
(bug 14022) Added usprop=registration and auprop=blockinfo
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllUsers.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryUsers.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryAllUsers.php
@@ -49,22 +49,28 @@
5050 $fld_editcount = isset($prop['editcount']);
5151 $fld_groups = isset($prop['groups']);
5252 $fld_registration = isset($prop['registration']);
 53+ $fld_blockinfo = isset($prop['blockinfo']);
5354 } else {
54 - $fld_editcount = $fld_groups = $fld_registration = false;
 55+ $fld_editcount = $fld_groups = $fld_registration = $fld_blockinfo = false;
5556 }
5657
5758 $limit = $params['limit'];
5859
5960 if( !is_null( $params['from'] ) )
60 - $this->addWhere( 'user_name >= ' . $db->addQuotes( self::keyToTitle( $params['from'] ) ) );
 61+ $this->addWhere( 'u1.user_name >= ' . $db->addQuotes( self::keyToTitle( $params['from'] ) ) );
6162
6263 if( isset( $params['prefix'] ) )
63 - $this->addWhere( 'user_name LIKE "' . $db->escapeLike( self::keyToTitle( $params['prefix'] ) ) . '%"' );
 64+ $this->addWhere( 'u1.user_name LIKE "' . $db->escapeLike( self::keyToTitle( $params['prefix'] ) ) . '%"' );
6465
 66+ $join = false;
 67+ $tables = array('user');
 68+ $types = array();
 69+ $conds = array();
 70+ $aliases = array('u1');
6571 if (!is_null($params['group'])) {
6672 // Filter only users that belong to a given group
6773 $this->addTables('user_groups', 'ug1');
68 - $this->addWhere('ug1.ug_user=user_id');
 74+ $this->addWhere('ug1.ug_user=u1.user_id');
6975 $this->addWhereFld('ug1.ug_group', $params['group']);
7076 }
7177 if ($fld_groups) {
@@ -72,26 +78,43 @@
7379 // request more than needed to avoid not getting all rows that belong to one user
7480 $groupCount = count(User::getAllGroups());
7581 $sqlLimit = $limit+$groupCount+1;
76 - $this->addJoin(
77 - array('user', 'user_groups'),
78 - array(ApiQueryBase::LEFT_JOIN),
79 - array('ug2.ug_user=user_id'),
80 - array(null, 'ug2'));
 82+
 83+ $join = true;
 84+ $tables[] = 'user_groups';
 85+ $types[] = ApiQueryBase::LEFT_JOIN;
 86+ $conds[] = 'ug2.ug_user=u1.user_id';
 87+ $aliases[] = 'ug2';
8188 $this->addFields('ug2.ug_group ug_group2');
8289 } else {
83 - $this->addTables('user');
8490 $sqlLimit = $limit+1;
8591 }
 92+ if ($fld_blockinfo) {
 93+ $join = true;
 94+ $tables[] = 'ipblocks';
 95+ $types[] = ApiQueryBase::LEFT_JOIN;
 96+ $conds[] = 'ipb_user=u1.user_id';
 97+ $aliases[] = null;
 98+
 99+ $tables[] = 'user';
 100+ $types[] = ApiQueryBase::LEFT_JOIN;
 101+ $conds[] = 'ipb_by=u2.user_id';
 102+ $aliases[] = 'u2';
 103+ $this->addFields(array('ipb_reason', 'u2.user_name AS blocker_name'));
 104+ }
 105+
 106+ if ($join) {
 107+ $this->addJoin($tables, $types, $conds, $aliases);
 108+ } else {
 109+ $this->addTables('user', 'u1');
 110+ }
86111
87 - if ($fld_registration)
88 - $this->addFields('user_registration');
89 -
90112 $this->addOption('LIMIT', $sqlLimit);
91113
92 - $this->addFields('user_name');
93 - $this->addFieldsIf('user_editcount', $fld_editcount);
 114+ $this->addFields('u1.user_name');
 115+ $this->addFieldsIf('u1.user_editcount', $fld_editcount);
 116+ $this->addFieldsIf('u1.user_registration', $fld_registration);
94117
95 - $this->addOption('ORDER BY', 'user_name');
 118+ $this->addOption('ORDER BY', 'u1.user_name');
96119
97120 $res = $this->select(__METHOD__);
98121
@@ -135,6 +158,10 @@
136159 $lastUserData['editcount'] = intval($row->user_editcount);
137160 if ($fld_registration)
138161 $lastUserData['registration'] = wfTimestamp(TS_ISO_8601, $row->user_registration);
 162+ if ($fld_blockinfo && !is_null($row->blocker_name)) {
 163+ $lastUserData['blockedby'] = $row->blocker_name;
 164+ $lastUserData['blockreason'] = $row->ipb_reason;
 165+ }
139166
140167 }
141168
@@ -171,6 +198,7 @@
172199 'editcount',
173200 'groups',
174201 'registration',
 202+ 'blockinfo'
175203 )
176204 ),
177205 'limit' => array (
Index: trunk/phase3/includes/api/ApiQueryUsers.php
@@ -75,6 +75,7 @@
7676 $this->addFields('u1.user_name');
7777 $this->addWhereFld('u1.user_name', $goodNames);
7878 $this->addFieldsIf('u1.user_editcount', isset($this->prop['editcount']));
 79+ $this->addFieldsIf('u1.user_registration', isset($this->prop['registration']));
7980
8081 $join = false;
8182 $tables = array('user');
@@ -114,6 +115,8 @@
115116 $data[$r->user_name]['name'] = $r->user_name;
116117 if(isset($this->prop['editcount']))
117118 $data[$r->user_name]['editcount'] = $r->user_editcount;
 119+ if(isset($this->prop['registration']))
 120+ $data[$r->user_name]['registration'] = wfTimestamp(TS_ISO_8601, $r->user_registration);
118121 if(isset($this->prop['groups']))
119122 // This row contains only one group, others will be added from other rows
120123 if(!is_null($r->ug_group))
@@ -146,7 +149,8 @@
147150 ApiBase :: PARAM_TYPE => array (
148151 'blockinfo',
149152 'groups',
150 - 'editcount'
 153+ 'editcount',
 154+ 'registration'
151155 )
152156 ),
153157 'users' => array(
Index: trunk/phase3/RELEASE-NOTES
@@ -325,6 +325,7 @@
326326 * (bug 14018) Introduced alcontinue to list=alllinks to improve paging
327327 * (bug 14013) Added rcshow=patrolled to list=recentchanges
328328 * (bug 14028) Added language attribute to interwiki map in meta=siteinfo
 329+* (bug 14022) Added usprop=registration and auprop=blockinfo
329330
330331 === Languages updated in 1.13 ===
331332

Follow-up revisions

RevisionCommit summaryAuthorDate
r34565* Re-applying r34449, r34500 and r34518 which Brion reverted by accident...catrope10:49, 10 May 2008

Status & tagging log