Update formatting on more API classes
authorSiebrand Mazeland <s.mazeland@xs4all.nl>
Thu, 14 Nov 2013 12:42:04 +0000 (13:42 +0100)
committerChad <chadh@wikimedia.org>
Thu, 14 Nov 2013 18:11:13 +0000 (18:11 +0000)
Change-Id: I1e6325b628359a557ceaa1e1ae30043aa5fc1402

includes/api/ApiFormatRaw.php
includes/api/ApiFormatWddx.php
includes/api/ApiFormatXml.php
includes/api/ApiHelp.php
includes/api/ApiImageRotate.php
includes/api/ApiImport.php
includes/api/ApiLogin.php
includes/api/ApiMain.php
includes/api/ApiModuleManager.php
includes/api/ApiMove.php

index d278efa..45003e9 100644 (file)
@@ -58,6 +58,7 @@ class ApiFormatRaw extends ApiFormatBase {
                $data = $this->getResultData();
                if ( isset( $data['error'] ) ) {
                        $this->mErrorFallback->execute();
+
                        return;
                }
 
index 5685d93..eb83198 100644 (file)
@@ -40,8 +40,9 @@ class ApiFormatWddx extends ApiFormatBase {
                // to avoid this.
                $expected = "<wddxPacket version='1.0'><header/><data><string>\xc2\xa0</string></data></wddxPacket>";
                if ( function_exists( 'wddx_serialize_value' )
-                               && !$this->getIsHtml()
-                               && wddx_serialize_value( "\xc2\xa0" ) == $expected ) {
+                       && !$this->getIsHtml()
+                       && wddx_serialize_value( "\xc2\xa0" ) == $expected
+               ) {
                        $this->printText( wddx_serialize_value( $this->getResultData() ) );
                } else {
                        // Don't do newlines and indentation if we weren't asked
index 4ec149c..0917ac7 100644 (file)
@@ -69,7 +69,7 @@ class ApiFormatXml extends ApiFormatBase {
                $this->printText(
                        self::recXmlPrint( $this->mRootElemName,
                                $data,
-                               $this->getIsHtml() ? - 2 : null
+                               $this->getIsHtml() ? -2 : null
                        )
                );
        }
@@ -193,6 +193,7 @@ class ApiFormatXml extends ApiFormatBase {
                                $retval .= $indstr . Xml::element( $elemName, null, $elemValue );
                        }
                }
+
                return $retval;
        }
 
@@ -200,14 +201,17 @@ class ApiFormatXml extends ApiFormatBase {
                $nt = Title::newFromText( $this->mXslt );
                if ( is_null( $nt ) || !$nt->exists() ) {
                        $this->setWarning( 'Invalid or non-existent stylesheet specified' );
+
                        return;
                }
                if ( $nt->getNamespace() != NS_MEDIAWIKI ) {
                        $this->setWarning( 'Stylesheet should be in the MediaWiki namespace.' );
+
                        return;
                }
-               if ( substr( $nt->getText(), - 4 ) !== '.xsl' ) {
+               if ( substr( $nt->getText(), -4 ) !== '.xsl' ) {
                        $this->setWarning( 'Stylesheet should have .xsl extension.' );
+
                        return;
                }
                $this->printText( '<?xml-stylesheet href="' . htmlspecialchars( $nt->getLocalURL( 'action=raw' ) ) . '" type="text/xsl" ?>' );
index 9cafc5b..1aa300a 100644 (file)
@@ -78,9 +78,9 @@ class ApiHelp extends ApiBase {
                                }
                                if ( $module === null ) {
                                        if ( count( $subNames ) === 2
-                                                       && $i === 1
-                                                       && $subNames[0] === 'query'
-                                                       && in_array( $subNames[1], $queryModules )
+                                               && $i === 1
+                                               && $subNames[0] === 'query'
+                                               && in_array( $subNames[1], $queryModules )
                                        ) {
                                                // Legacy: This is one of the renamed 'querymodule=...' parameters,
                                                // do not use '+' notation in the output, use submodule's name instead.
index 7a60e83..1a8f2a6 100644 (file)
@@ -145,6 +145,7 @@ class ApiImageRotate extends ApiBase {
                if ( $this->mPageSet === null ) {
                        $this->mPageSet = new ApiPageSet( $this, 0, NS_FILE );
                }
+
                return $this->mPageSet;
        }
 
@@ -163,6 +164,7 @@ class ApiImageRotate extends ApiBase {
                if ( $permissionErrors ) {
                        // Just return the first error
                        $msg = $this->parseMsg( $permissionErrors[0] );
+
                        return $msg['info'];
                }
 
@@ -191,11 +193,13 @@ class ApiImageRotate extends ApiBase {
                if ( $flags ) {
                        $result += $this->getPageSet()->getFinalParams( $flags );
                }
+
                return $result;
        }
 
        public function getParamDescription() {
                $pageSet = $this->getPageSet();
+
                return $pageSet->getFinalParamDescription() + array(
                        'rotation' => 'Degrees to rotate image clockwise',
                        'token' => 'Edit token. You can get one of these through action=tokens',
@@ -216,6 +220,7 @@ class ApiImageRotate extends ApiBase {
 
        public function getPossibleErrors() {
                $pageSet = $this->getPageSet();
+
                return array_merge(
                        parent::getPossibleErrors(),
                        $pageSet->getFinalPossibleErrors()
index f48a822..9253964 100644 (file)
@@ -99,6 +99,7 @@ class ApiImport extends ApiBase {
 
        public function getAllowedParams() {
                global $wgImportSources;
+
                return array(
                        'token' => array(
                                ApiBase::PARAM_TYPE => 'string',
index 13e58b8..18fd0c7 100644 (file)
@@ -52,6 +52,7 @@ class ApiLogin extends ApiBase {
                                'result' => 'Aborted',
                                'reason' => 'Cannot log in when using a callback',
                        ) );
+
                        return;
                }
 
index c11f16c..61577cb 100644 (file)
@@ -191,7 +191,7 @@ class ApiMain extends ApiBase {
                $this->mResult = new ApiResult( $this );
                $this->mEnableWrite = $enableWrite;
 
-               $this->mSquidMaxage = - 1; // flag for executeActionWithErrorHandling()
+               $this->mSquidMaxage = -1; // flag for executeActionWithErrorHandling()
                $this->mCommit = false;
        }
 
@@ -270,6 +270,7 @@ class ApiMain extends ApiBase {
        public function setCacheMode( $mode ) {
                if ( !in_array( $mode, array( 'private', 'public', 'anon-public-user-private' ) ) ) {
                        wfDebug( __METHOD__ . ": unrecognised cache mode \"$mode\"\n" );
+
                        // Ignore for forwards-compatibility
                        return;
                }
@@ -278,6 +279,7 @@ class ApiMain extends ApiBase {
                        // Private wiki, only private headers
                        if ( $mode !== 'private' ) {
                                wfDebug( __METHOD__ . ": ignoring request for $mode cache mode, private wiki\n" );
+
                                return;
                        }
                }
@@ -337,6 +339,7 @@ class ApiMain extends ApiBase {
                if ( $printer === null ) {
                        $this->dieUsage( "Unrecognized format: {$format}", 'unknown_format' );
                }
+
                return $printer;
        }
 
@@ -463,6 +466,7 @@ class ApiMain extends ApiBase {
                        $response->header( "HTTP/1.1 403 $message", true, 403 );
                        $response->header( 'Cache-Control: no-cache' );
                        echo "'origin' parameter does not match Origin header\n";
+
                        return false;
                }
                if ( self::matchOrigin( $originParam, $wgCrossSiteAJAXdomains, $wgCrossSiteAJAXdomainExceptions ) ) {
@@ -470,6 +474,7 @@ class ApiMain extends ApiBase {
                        $response->header( 'Access-Control-Allow-Credentials: true' );
                        $this->getOutput()->addVaryHeader( 'Origin' );
                }
+
                return true;
        }
 
@@ -489,9 +494,11 @@ class ApiMain extends ApiBase {
                                                return false;
                                        }
                                }
+
                                return true;
                        }
                }
+
                return false;
        }
 
@@ -510,6 +517,7 @@ class ApiMain extends ApiBase {
                        array( '.*?', '.' ),
                        $wildcard
                );
+
                return "/https?:\/\/$wildcard/";
        }
 
@@ -524,6 +532,7 @@ class ApiMain extends ApiBase {
 
                if ( $this->mCacheMode == 'private' ) {
                        $response->header( 'Cache-Control: private' );
+
                        return;
                }
 
@@ -535,6 +544,7 @@ class ApiMain extends ApiBase {
                                if ( $out->haveCacheVaryCookies() ) {
                                        // Logged in, mark this request private
                                        $response->header( 'Cache-Control: private' );
+
                                        return;
                                }
                                // Logged out, send normal public headers below
@@ -542,6 +552,7 @@ class ApiMain extends ApiBase {
                                // Logged in or otherwise has session (e.g. anonymous users who have edited)
                                // Mark request private
                                $response->header( 'Cache-Control: private' );
+
                                return;
                        } // else no XVO and anonymous, send public headers below
                }
@@ -565,6 +576,7 @@ class ApiMain extends ApiBase {
                        // Sending a Vary header in this case is harmless, and protects us
                        // against conditional calls of setCacheMaxAge().
                        $response->header( 'Cache-Control: private' );
+
                        return;
                }
 
@@ -720,6 +732,7 @@ class ApiMain extends ApiBase {
                                }
                        }
                }
+
                return $module;
        }
 
@@ -746,9 +759,11 @@ class ApiMain extends ApiBase {
                                } else {
                                        $this->dieUsage( "Waiting for a database server: $lag seconds lagged", 'maxlag' );
                                }
+
                                return false;
                        }
                }
+
                return true;
        }
 
@@ -759,8 +774,8 @@ class ApiMain extends ApiBase {
        protected function checkExecutePermissions( $module ) {
                $user = $this->getUser();
                if ( $module->isReadMode() && !User::isEveryoneAllowed( 'read' ) &&
-                       !$user->isAllowed( 'read' ) )
-               {
+                       !$user->isAllowed( 'read' )
+               {
                        $this->dieUsageMsg( 'readrequired' );
                }
                if ( $module->isWriteMode() ) {
@@ -881,6 +896,7 @@ class ApiMain extends ApiBase {
                                $table[rawurlencode( $chars[$i] )] = $chars[$i];
                        }
                }
+
                return strtr( rawurlencode( $s ), $table );
        }
 
@@ -896,6 +912,7 @@ class ApiMain extends ApiBase {
         */
        public function getVal( $name, $default = null ) {
                $this->mParamsUsed[$name] = true;
+
                return $this->getRequest()->getVal( $name, $default );
        }
 
@@ -905,6 +922,7 @@ class ApiMain extends ApiBase {
         */
        public function getCheck( $name ) {
                $this->mParamsUsed[$name] = true;
+
                return $this->getRequest()->getCheck( $name );
        }
 
@@ -917,6 +935,7 @@ class ApiMain extends ApiBase {
         */
        public function getUpload( $name ) {
                $this->mParamsUsed[$name] = true;
+
                return $this->getRequest()->getUpload( $name );
        }
 
@@ -932,7 +951,7 @@ class ApiMain extends ApiBase {
                        // Printer has not yet executed; don't warn that its parameters are unused
                        $printerParams = array_map(
                                array( $this->mPrinter, 'encodeParamName' ),
-                               array_keys( $this->mPrinter->getFinalParams() ?: array() )
+                               array_keys( $this->mPrinter->getFinalParams() ? : array() )
                        );
                        $unusedParams = array_diff( $allParams, $paramsUsed, $printerParams );
                } else {
@@ -1150,6 +1169,7 @@ class ApiMain extends ApiBase {
                if ( $wgAPICacheHelpTimeout > 0 ) {
                        $wgMemc->set( $key, $retval, $wgAPICacheHelpTimeout );
                }
+
                return $retval;
        }
 
@@ -1180,7 +1200,7 @@ class ApiMain extends ApiBase {
                foreach ( self::$mRights as $right => $rightMsg ) {
                        $groups = User::getGroupsWithPermission( $right );
                        $msg .= "* " . $right . " *\n  " . wfMsgReplaceArgs( $rightMsg['msg'], $rightMsg['params'] ) .
-                                               "\nGranted to:\n  " . str_replace( '*', 'all', implode( ', ', $groups ) ) . "\n\n";
+                               "\nGranted to:\n  " . str_replace( '*', 'all', implode( ', ', $groups ) ) . "\n\n";
                }
 
                $msg .= "\n$astriks Formats  $astriks\n\n";
@@ -1234,6 +1254,7 @@ class ApiMain extends ApiBase {
         */
        public function getShowVersions() {
                wfDeprecated( __METHOD__, '1.21' );
+
                return false;
        }
 
@@ -1336,6 +1357,7 @@ class UsageException extends MWException {
                if ( is_array( $this->mExtraData ) ) {
                        $result = array_merge( $result, $this->mExtraData );
                }
+
                return $result;
        }
 
index 100392b..407e089 100644 (file)
@@ -97,6 +97,7 @@ class ApiModuleManager extends ContextSource {
                                // cache this instance in case it is needed later
                                $this->mInstances[$moduleName] = $instance;
                        }
+
                        return $instance;
                }
        }
@@ -116,6 +117,7 @@ class ApiModuleManager extends ContextSource {
                                $result[] = $name;
                        }
                }
+
                return $result;
        }
 
@@ -131,6 +133,7 @@ class ApiModuleManager extends ContextSource {
                                $result[$name] = $grpCls[1];
                        }
                }
+
                return $result;
        }
 
index c18036c..c2d0959 100644 (file)
@@ -61,8 +61,8 @@ class ApiMove extends ApiBase {
 
                if ( $toTitle->getNamespace() == NS_FILE
                        && !RepoGroup::singleton()->getLocalRepo()->findFile( $toTitle )
-                       && wfFindFile( $toTitle ) )
-               {
+                       && wfFindFile( $toTitle )
+               {
                        if ( !$params['ignorewarnings'] && $user->isAllowed( 'reupload-shared' ) ) {
                                $this->dieUsageMsg( 'sharedfile-exists' );
                        } elseif ( !$user->isAllowed( 'reupload-shared' ) ) {
@@ -115,7 +115,7 @@ class ApiMove extends ApiBase {
                // Move subpages
                if ( $params['movesubpages'] ) {
                        $r['subpages'] = $this->moveSubpages( $fromTitle, $toTitle,
-                                       $params['reason'], $params['noredirect'] );
+                               $params['reason'], $params['noredirect'] );
                        $result->setIndexedTagName( $r['subpages'], 'subpage' );
 
                        if ( $params['movetalk'] ) {
@@ -167,6 +167,7 @@ class ApiMove extends ApiBase {
                                $retval[] = $r;
                        }
                }
+
                return $retval;
        }
 
@@ -219,6 +220,7 @@ class ApiMove extends ApiBase {
 
        public function getParamDescription() {
                $p = $this->getModulePrefix();
+
                return array(
                        'from' => "Title of the page you want to move. Cannot be used together with {$p}fromid",
                        'fromid' => "Page ID of the page you want to move. Cannot be used together with {$p}from",