Merge "tests: Remove unused $wgMemc resets"
[lhc/web/wiklou.git] / includes / api / ApiBlock.php
index 72aee32..636baa7 100644 (file)
@@ -52,7 +52,13 @@ class ApiBlock extends ApiBase {
                if ( $user->isBlocked() ) {
                        $status = SpecialBlock::checkUnblockSelf( $params['user'], $user );
                        if ( $status !== true ) {
-                               $this->dieUsageMsg( array( $status ) );
+                               $msg = $this->parseMsg( $status );
+                               $this->dieUsage(
+                                       $msg['info'],
+                                       $msg['code'],
+                                       0,
+                                       array( 'blockinfo' => ApiQueryUserInfo::getBlockInfo( $user->getBlock() ) )
+                               );
                        }
                }
 
@@ -113,27 +119,13 @@ class ApiBlock extends ApiBase {
                }
 
                $res['reason'] = $params['reason'];
-               if ( $params['anononly'] ) {
-                       $res['anononly'] = '';
-               }
-               if ( $params['nocreate'] ) {
-                       $res['nocreate'] = '';
-               }
-               if ( $params['autoblock'] ) {
-                       $res['autoblock'] = '';
-               }
-               if ( $params['noemail'] ) {
-                       $res['noemail'] = '';
-               }
-               if ( $params['hidename'] ) {
-                       $res['hidename'] = '';
-               }
-               if ( $params['allowusertalk'] ) {
-                       $res['allowusertalk'] = '';
-               }
-               if ( $params['watchuser'] ) {
-                       $res['watchuser'] = '';
-               }
+               $res['anononly'] = $params['anononly'];
+               $res['nocreate'] = $params['nocreate'];
+               $res['autoblock'] = $params['autoblock'];
+               $res['noemail'] = $params['noemail'];
+               $res['hidename'] = $params['hidename'];
+               $res['allowusertalk'] = $params['allowusertalk'];
+               $res['watchuser'] = $params['watchuser'];
 
                $this->getResult()->addValue( null, $this->getModuleName(), $res );
        }
@@ -170,12 +162,14 @@ class ApiBlock extends ApiBase {
        }
 
        protected function getExamplesMessages() {
+               // @codingStandardsIgnoreStart Generic.Files.LineLength
                return array(
                        'action=block&user=192.0.2.5&expiry=3%20days&reason=First%20strike&token=123ABC'
                                => 'apihelp-block-example-ip-simple',
                        'action=block&user=Vandal&expiry=never&reason=Vandalism&nocreate=&autoblock=&noemail=&token=123ABC'
                                => 'apihelp-block-example-user-complex',
                );
+               // @codingStandardsIgnoreEnd
        }
 
        public function getHelpUrls() {