Randomize the JobRunner slave lags checks a bit
[lhc/web/wiklou.git] / includes / api / ApiQueryAllUsers.php
index b27f6c2..d241311 100644 (file)
@@ -111,35 +111,18 @@ class ApiQueryAllUsers extends ApiQueryBase {
                        }
                }
 
-               if ( !is_null( $params['group'] ) && !is_null( $params['excludegroup'] ) ) {
-                       $this->dieUsage( 'group and excludegroup cannot be used together', 'group-excludegroup' );
-               }
-
                if ( !is_null( $params['group'] ) && count( $params['group'] ) ) {
-                       $useIndex = false;
                        // Filter only users that belong to a given group
-                       $this->addTables( 'user_groups', 'ug1' );
-                       $this->addJoinConds( array( 'ug1' => array( 'INNER JOIN', array( 'ug1.ug_user=user_id',
-                               'ug1.ug_group' => $params['group'] ) ) ) );
+                       $this->addWhere( 'EXISTS (' . $db->selectSQLText(
+                               'user_groups', '1', array( 'ug_user=user_id', 'ug_group' => $params['group'] )
+                       ) . ')' );
                }
 
                if ( !is_null( $params['excludegroup'] ) && count( $params['excludegroup'] ) ) {
-                       $useIndex = false;
                        // Filter only users don't belong to a given group
-                       $this->addTables( 'user_groups', 'ug1' );
-
-                       if ( count( $params['excludegroup'] ) == 1 ) {
-                               $exclude = array( 'ug1.ug_group' => $params['excludegroup'][0] );
-                       } else {
-                               $exclude = array( $db->makeList(
-                                       array( 'ug1.ug_group' => $params['excludegroup'] ),
-                                       LIST_OR
-                               ) );
-                       }
-                       $this->addJoinConds( array( 'ug1' => array( 'LEFT OUTER JOIN',
-                               array_merge( array( 'ug1.ug_user=user_id' ), $exclude )
-                       ) ) );
-                       $this->addWhere( 'ug1.ug_user IS NULL' );
+                       $this->addWhere( 'NOT EXISTS (' . $db->selectSQLText(
+                               'user_groups', '1', array( 'ug_user=user_id', 'ug_group' => $params['excludegroup'] )
+                       ) . ')' );
                }
 
                if ( $params['witheditsonly'] ) {
@@ -156,7 +139,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
 
                        $this->addTables( 'user_groups', 'ug2' );
                        $this->addJoinConds( array( 'ug2' => array( 'LEFT JOIN', 'ug2.ug_user=user_id' ) ) );
-                       $this->addFields( 'ug2.ug_group ug_group2' );
+                       $this->addFields( array( 'ug_group2' => 'ug2.ug_group' ) );
                } else {
                        $sqlLimit = $limit + 1;
                }
@@ -256,6 +239,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                                        $lastUserData['blockid'] = $row->ipb_id;
                                        $lastUserData['blockedby'] = $row->ipb_by_text;
                                        $lastUserData['blockedbyid'] = $row->ipb_by;
+                                       $lastUserData['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $row->ipb_timestamp );
                                        $lastUserData['blockreason'] = $row->ipb_reason;
                                        $lastUserData['blockexpiry'] = $row->ipb_expiry;
                                }
@@ -421,61 +405,10 @@ class ApiQueryAllUsers extends ApiQueryBase {
                );
        }
 
-       public function getResultProperties() {
-               return array(
-                       '' => array(
-                               'userid' => 'integer',
-                               'name' => 'string',
-                               'recentactions' => array(
-                                       ApiBase::PROP_TYPE => 'integer',
-                                       ApiBase::PROP_NULLABLE => true
-                               )
-                       ),
-                       'blockinfo' => array(
-                               'blockid' => array(
-                                       ApiBase::PROP_TYPE => 'integer',
-                                       ApiBase::PROP_NULLABLE => true
-                               ),
-                               'blockedby' => array(
-                                       ApiBase::PROP_TYPE => 'string',
-                                       ApiBase::PROP_NULLABLE => true
-                               ),
-                               'blockedbyid' => array(
-                                       ApiBase::PROP_TYPE => 'integer',
-                                       ApiBase::PROP_NULLABLE => true
-                               ),
-                               'blockedreason' => array(
-                                       ApiBase::PROP_TYPE => 'string',
-                                       ApiBase::PROP_NULLABLE => true
-                               ),
-                               'blockedexpiry' => array(
-                                       ApiBase::PROP_TYPE => 'string',
-                                       ApiBase::PROP_NULLABLE => true
-                               ),
-                               'hidden' => 'boolean'
-                       ),
-                       'editcount' => array(
-                               'editcount' => 'integer'
-                       ),
-                       'registration' => array(
-                               'registration' => 'string'
-                       )
-               );
-       }
-
        public function getDescription() {
                return 'Enumerate all registered users.';
        }
 
-       public function getPossibleErrors() {
-               return array_merge( parent::getPossibleErrors(), array(
-                       array(
-                               'code' => 'group-excludegroup',
-                               'info' => 'group and excludegroup cannot be used together'
-                       ),
-               ) );
-       }
-
        public function getExamples() {
                return array(
                        'api.php?action=query&list=allusers&aufrom=Y',