Merge "Added LogEntryBase::extractParams/makeParamBlob"
[lhc/web/wiklou.git] / includes / api / ApiQueryBlocks.php
index 159b1c8..f6bde41 100644 (file)
  */
 class ApiQueryBlocks extends ApiQueryBase {
 
-       /**
-        * @var array
-        */
-       protected $usernames;
-
        public function __construct( ApiQuery $query, $moduleName ) {
                parent::__construct( $query, $moduleName, 'bk' );
        }
@@ -62,12 +57,11 @@ class ApiQueryBlocks extends ApiQueryBase {
                $result = $this->getResult();
 
                $this->addTables( 'ipblocks' );
-               $this->addFields( array( 'ipb_auto', 'ipb_id' ) );
+               $this->addFields( array( 'ipb_auto', 'ipb_id', 'ipb_timestamp' ) );
 
                $this->addFieldsIf( array( 'ipb_address', 'ipb_user' ), $fld_user || $fld_userid );
                $this->addFieldsIf( 'ipb_by_text', $fld_by );
                $this->addFieldsIf( 'ipb_by', $fld_byid );
-               $this->addFieldsIf( 'ipb_timestamp', $fld_timestamp );
                $this->addFieldsIf( 'ipb_expiry', $fld_expiry );
                $this->addFieldsIf( 'ipb_reason', $fld_reason );
                $this->addFieldsIf( array( 'ipb_range_start', 'ipb_range_end' ), $fld_range );
@@ -102,10 +96,11 @@ class ApiQueryBlocks extends ApiQueryBase {
                        $this->addWhereFld( 'ipb_id', $params['ids'] );
                }
                if ( isset( $params['users'] ) ) {
+                       $usernames = array();
                        foreach ( (array)$params['users'] as $u ) {
-                               $this->prepareUsername( $u );
+                               $usernames[] = $this->prepareUsername( $u );
                        }
-                       $this->addWhereFld( 'ipb_address', $this->usernames );
+                       $this->addWhereFld( 'ipb_address', $usernames );
                        $this->addWhereFld( 'ipb_auto', 0 );
                }
                if ( isset( $params['ip'] ) ) {
@@ -264,7 +259,7 @@ class ApiQueryBlocks extends ApiQueryBase {
                if ( $name === false ) {
                        $this->dieUsage( "User name {$user} is not valid", 'param_user' );
                }
-               $this->usernames[] = $name;
+               return $name;
        }
 
        public function getAllowedParams() {
@@ -341,7 +336,7 @@ class ApiQueryBlocks extends ApiQueryBase {
                );
        }
 
-       public function getExamplesMessages() {
+       protected function getExamplesMessages() {
                return array(
                        'action=query&list=blocks'
                                => 'apihelp-query+blocks-example-simple',