'none' => 'ApiFormatNone',
);
+ // @codingStandardsIgnoreStart String contenation on "msg" not allowed to break long line
/**
* List of user roles that are specifically relevant to the API.
* array( 'right' => array ( 'msg' => 'Some message with a $1',
'params' => array( ApiBase::LIMIT_SML2, ApiBase::LIMIT_BIG2 )
)
);
+ // @codingStandardsIgnoreEnd
/**
* @var ApiFormatBase
/**
* Constructs an instance of ApiMain that utilizes the module and format specified by $request.
*
- * @param $context IContextSource|WebRequest - if this is an instance of FauxRequest, errors are thrown and no printing occurs
+ * @param $context IContextSource|WebRequest - if this is an instance of
+ * FauxRequest, errors are thrown and no printing occurs
* @param bool $enableWrite should be set to true if the api may modify data
*/
public function __construct( $context = null, $enableWrite = false ) {
} else {
$origins = explode( ' ', $originHeader );
}
+
if ( !in_array( $originParam, $origins ) ) {
// origin parameter set but incorrect
// Send a 403 response
return false;
}
- if ( self::matchOrigin( $originParam, $wgCrossSiteAJAXdomains, $wgCrossSiteAJAXdomainExceptions ) ) {
+
+ $matchOrigin = self::matchOrigin(
+ $originParam,
+ $wgCrossSiteAJAXdomains,
+ $wgCrossSiteAJAXdomainExceptions
+ );
+
+ if ( $matchOrigin ) {
$response->header( "Access-Control-Allow-Origin: $originParam" );
$response->header( 'Access-Control-Allow-Credentials: true' );
$this->getOutput()->addVaryHeader( 'Origin' );
* @param string $value Origin header
* @param array $rules Set of wildcard rules
* @param array $exceptions Set of wildcard rules
- * @return bool True if $value matches a rule in $rules and doesn't match any rules in $exceptions, false otherwise
+ * @return bool True if $value matches a rule in $rules and doesn't match
+ * any rules in $exceptions, false otherwise
*/
protected static function matchOrigin( $value, $rules, $exceptions ) {
foreach ( $rules as $rule ) {
'code' => 'internal_api_error_' . get_class( $e ),
'info' => $info,
);
- ApiResult::setContent( $errMessage, $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : '' );
+ ApiResult::setContent(
+ $errMessage,
+ $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : ''
+ );
}
// Remember all the warnings to re-add them later
if ( !isset( $moduleParams['token'] ) ) {
$this->dieUsageMsg( array( 'missingparam', 'token' ) );
} else {
- if ( !$this->getUser()->matchEditToken( $moduleParams['token'], $salt, $this->getContext()->getRequest() ) ) {
+ if ( !$this->getUser()
+ ->matchEditToken( $moduleParams['token'], $salt, $this->getContext()->getRequest() )
+ ) {
$this->dieUsageMsg( 'sessionfailure' );
}
}
static $table;
if ( !$table ) {
$chars = ';@$!*(),/:';
- for ( $i = 0; $i < strlen( $chars ); $i++ ) {
+ $numChars = strlen( $chars );
+ for ( $i = 0; $i < $numChars; $i++ ) {
$table[rawurlencode( $chars[$i] )] = $chars[$i];
}
}
'smaxage' => 'Set the s-maxage header to this many seconds. Errors are never cached',
'maxage' => 'Set the max-age header to this many seconds. Errors are never cached',
'requestid' => 'Request ID to distinguish requests. This will just be output back to you',
- 'servedby' => 'Include the hostname that served the request in the results. Unconditionally shown on error',
+ 'servedby' => 'Include the hostname that served the request in the ' .
+ 'results. Unconditionally shown on error',
'origin' => array(
- 'When accessing the API using a cross-domain AJAX request (CORS), set this to the originating domain.',
- 'This must be included in any pre-flight request, and therefore must be part of the request URI (not the POST body).',
- 'This must match one of the origins in the Origin: header exactly, so it has to be set to something like http://en.wikipedia.org or https://meta.wikimedia.org .',
- 'If this parameter does not match the Origin: header, a 403 response will be returned.',
- 'If this parameter matches the Origin: header and the origin is whitelisted, an Access-Control-Allow-Origin header will be set.',
+ 'When accessing the API using a cross-domain AJAX request (CORS), set this to the',
+ 'originating domain. This must be included in any pre-flight request, and',
+ 'therefore must be part of the request URI (not the POST body). This must match',
+ 'one of the origins in the Origin: header exactly, so it has to be set to ',
+ 'something like http://en.wikipedia.org or https://meta.wikimedia.org . If this',
+ 'parameter does not match the Origin: header, a 403 response will be returned. If',
+ 'this parameter matches the Origin: header and the origin is whitelisted, an',
+ 'Access-Control-Allow-Origin header will be set.',
),
);
}
return array(
'',
'',
- '**********************************************************************************************************',
- '** **',
- '** This is an auto-generated MediaWiki API documentation page **',
- '** **',
- '** Documentation and Examples: **',
- '** https://www.mediawiki.org/wiki/API **',
- '** **',
- '**********************************************************************************************************',
+ '**********************************************************************************************',
+ '** **',
+ '** This is an auto-generated MediaWiki API documentation page **',
+ '** **',
+ '** Documentation and Examples: **',
+ '** https://www.mediawiki.org/wiki/API **',
+ '** **',
+ '**********************************************************************************************',
'',
'Status: All features shown on this page should be working, but the API',
' is still in active development, and may change at any time.',
' In the case of an invalid action being passed, these will have a value',
' of "unknown_action"',
'',
- ' For more information see https://www.mediawiki.org/wiki/API:Errors_and_warnings',
+ ' For more information see https://www.mediawiki.org' .
+ '/wiki/API:Errors_and_warnings',
'',
'Documentation: https://www.mediawiki.org/wiki/API:Main_page',
'FAQ https://www.mediawiki.org/wiki/API:FAQ',
'Mailing list: https://lists.wikimedia.org/mailman/listinfo/mediawiki-api',
'Api Announcements: https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce',
- 'Bugs & Requests: https://bugzilla.wikimedia.org/buglist.cgi?component=API&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&order=bugs.delta_ts',
+ 'Bugs & Requests: https://bugzilla.wikimedia.org/buglist.cgi?component=API&' .
+ 'bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&order=bugs.delta_ts',
'',
'',
'',
' Victor Vasiliev - vasilvv @ gmail . com',
' Bryan Tong Minh - bryan . tongminh @ gmail . com',
' Sam Reed - sam @ reedyboy . net',
- ' Yuri Astrakhan "<Firstname><Lastname>@gmail.com" (creator, lead developer Sep 2006-Sep 2007, 2012-present)',
+ ' Yuri Astrakhan "<Firstname><Lastname>@gmail.com" (creator, lead ' .
+ 'developer Sep 2006-Sep 2007, 2012-present)',
'',
'Please send your comments, suggestions and questions to mediawiki-api@lists.wikimedia.org',
'or file a bug report at https://bugzilla.wikimedia.org/'
/**
* @param $module ApiBase
- * @param string $paramName What type of request is this? e.g. action, query, list, prop, meta, format
+ * @param string $paramName What type of request is this? e.g. action,
+ * query, list, prop, meta, format
* @return string
*/
public static function makeHelpMsgHeader( $module, $paramName ) {