r82739 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82738‎ | r82739 | r82740 >
Date:18:43, 24 February 2011
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
* (bug 27688) Simplify queries to list user block information

Also expose block expiry information, listed on Users, but not all users

Some minor simplifications to come
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
@@ -114,12 +114,10 @@
115115
116116 if ( $fld_blockinfo ) {
117117 $this->addTables( 'ipblocks' );
118 - $this->addTables( 'user', 'u2' );
119 - $u2 = $this->getAliasedName( 'user', 'u2' );
120118 $this->addJoinConds( array(
121119 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=u1.user_id' ),
122 - $u2 => array( 'LEFT JOIN', 'ipb_by=u2.user_id' ) ) );
123 - $this->addFields( array( 'ipb_reason', 'u2.user_name AS blocker_name' ) );
 120+ ) );
 121+ $this->addFields( array( 'ipb_reason', 'ipb_by_text', 'ipb_expiry' ) );
124122 }
125123
126124 $this->addOption( 'LIMIT', $sqlLimit );
@@ -181,9 +179,10 @@
182180 'name' => $lastUser,
183181 'userid' => $row->user_id,
184182 );
185 - if ( $fld_blockinfo && !is_null( $row->blocker_name ) ) {
186 - $lastUserData['blockedby'] = $row->blocker_name;
 183+ if ( $fld_blockinfo && !is_null( $row->ipb_by_text ) ) {
 184+ $lastUserData['blockedby'] = $row->ipb_by_text;
187185 $lastUserData['blockreason'] = $row->ipb_reason;
 186+ $lastUserData['blockexpiry'] = $row->ipb_expiry;
188187 }
189188 if ( $fld_editcount ) {
190189 $lastUserData['editcount'] = intval( $row->user_editcount );
Index: trunk/phase3/includes/api/ApiQueryUsers.php
@@ -121,12 +121,10 @@
122122 }
123123 if ( isset( $this->prop['blockinfo'] ) ) {
124124 $this->addTables( 'ipblocks' );
125 - $this->addTables( 'user', 'u2' );
126 - $u2 = $this->getAliasedName( 'user', 'u2' );
127125 $this->addJoinConds( array(
128126 'ipblocks' => array( 'LEFT JOIN', 'ipb_user=u1.user_id' ),
129 - $u2 => array( 'LEFT JOIN', 'ipb_by=u2.user_id' ) ) );
130 - $this->addFields( array( 'ipb_reason', 'u2.user_name AS blocker_name', 'ipb_expiry' ) );
 127+ ) );
 128+ $this->addFields( array( 'ipb_reason', 'ipb_by_text', 'ipb_expiry' ) );
131129 }
132130
133131 $data = array();
@@ -168,7 +166,7 @@
169167 }
170168
171169 if ( isset( $this->prop['blockinfo'] ) && !is_null( $row->blocker_name ) ) {
172 - $data[$name]['blockedby'] = $row->blocker_name;
 170+ $data[$name]['blockedby'] = $row->ipb_by_text;
173171 $data[$name]['blockreason'] = $row->ipb_reason;
174172 $data[$name]['blockexpiry'] = $row->ipb_expiry;
175173 }
Index: trunk/phase3/RELEASE-NOTES
@@ -179,6 +179,7 @@
180180 * (bug 27554) Update api information text to reflect change in bug 26125
181181 * (bug 27611) list=blocks: Use ipb_by_text instead of join with user table
182182 * (bug 27616) Add userid of blocked user and blocker to list=blocks
 183+* (bug 27688) Simplify queries to list user block information
183184
184185 === Languages updated in 1.18 ===
185186

Follow-up revisions

RevisionCommit summaryAuthorDate
r82740Followup to r82739 (bug 27688)...reedy18:46, 24 February 2011
r82745Fixup one missed alias rename from r82739reedy20:46, 24 February 2011

Comments

#Comment by Duplicatebug (talk | contribs)   20:37, 24 February 2011

You left one $row->blocker_name in ApiQueryUsers.php

Status & tagging log