* (bug 27688) Simplify queries to list user block information
authorSam Reed <reedy@users.mediawiki.org>
Thu, 24 Feb 2011 18:43:44 +0000 (18:43 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Thu, 24 Feb 2011 18:43:44 +0000 (18:43 +0000)
Also expose block expiry information, listed on Users, but not all users

Some minor simplifications to come

RELEASE-NOTES
includes/api/ApiQueryAllUsers.php
includes/api/ApiQueryUsers.php

index a6322a2..52cc00a 100644 (file)
@@ -179,6 +179,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 27554) Update api information text to reflect change in bug 26125
 * (bug 27611) list=blocks: Use ipb_by_text instead of join with user table
 * (bug 27616) Add userid of blocked user and blocker to list=blocks
+* (bug 27688) Simplify queries to list user block information
 
 === Languages updated in 1.18 ===
 
index f2979fc..1cdc485 100644 (file)
@@ -114,12 +114,10 @@ class ApiQueryAllUsers extends ApiQueryBase {
 
                if ( $fld_blockinfo ) {
                        $this->addTables( 'ipblocks' );
-                       $this->addTables( 'user', 'u2' );
-                       $u2 = $this->getAliasedName( 'user', 'u2' );
                        $this->addJoinConds( array(
                                'ipblocks' => array( 'LEFT JOIN', 'ipb_user=u1.user_id' ),
-                               $u2 => array( 'LEFT JOIN', 'ipb_by=u2.user_id' ) ) );
-                       $this->addFields( array( 'ipb_reason', 'u2.user_name AS blocker_name' ) );
+                       ) );
+                       $this->addFields( array( 'ipb_reason', 'ipb_by_text', 'ipb_expiry' ) );
                }
 
                $this->addOption( 'LIMIT', $sqlLimit );
@@ -181,9 +179,10 @@ class ApiQueryAllUsers extends ApiQueryBase {
                                        'name' => $lastUser,
                                        'userid' => $row->user_id,
                                );
-                               if ( $fld_blockinfo && !is_null( $row->blocker_name ) ) {
-                                       $lastUserData['blockedby'] = $row->blocker_name;
+                               if ( $fld_blockinfo && !is_null( $row->ipb_by_text ) ) {
+                                       $lastUserData['blockedby'] = $row->ipb_by_text;
                                        $lastUserData['blockreason'] = $row->ipb_reason;
+                                       $lastUserData['blockexpiry'] = $row->ipb_expiry;
                                }
                                if ( $fld_editcount ) {
                                        $lastUserData['editcount'] = intval( $row->user_editcount );
index e29394b..7cec1e9 100644 (file)
@@ -121,12 +121,10 @@ if ( !defined( 'MEDIAWIKI' ) ) {
                        }
                        if ( isset( $this->prop['blockinfo'] ) ) {
                                $this->addTables( 'ipblocks' );
-                               $this->addTables( 'user', 'u2' );
-                               $u2 = $this->getAliasedName( 'user', 'u2' );
                                $this->addJoinConds( array(
                                        'ipblocks' => array( 'LEFT JOIN', 'ipb_user=u1.user_id' ),
-                                       $u2 => array( 'LEFT JOIN', 'ipb_by=u2.user_id' ) ) );
-                               $this->addFields( array( 'ipb_reason', 'u2.user_name AS blocker_name', 'ipb_expiry' ) );
+                               ) );
+                               $this->addFields( array( 'ipb_reason', 'ipb_by_text', 'ipb_expiry' ) );
                        }
 
                        $data = array();
@@ -168,7 +166,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
                                }
 
                                if ( isset( $this->prop['blockinfo'] ) && !is_null( $row->blocker_name ) ) {
-                                       $data[$name]['blockedby'] = $row->blocker_name;
+                                       $data[$name]['blockedby'] = $row->ipb_by_text;
                                        $data[$name]['blockreason'] = $row->ipb_reason;
                                        $data[$name]['blockexpiry'] = $row->ipb_expiry;
                                }