Siebrand has uploaded a new change for review. https://gerrit.wikimedia.org/r/95802
Change subject: Address errors and warnings in CodeSniffer in api/ ...................................................................... Address errors and warnings in CodeSniffer in api/ Change-Id: I06de371393d50eada33154626874b106d814642b --- M includes/api/ApiImport.php M includes/api/ApiLogin.php M includes/api/ApiMain.php M includes/api/ApiMove.php M includes/api/ApiOptions.php M includes/api/ApiQueryImageInfo.php 6 files changed, 99 insertions(+), 43 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/02/95802/1 diff --git a/includes/api/ApiImport.php b/includes/api/ApiImport.php index 9253964..295f16e 100644 --- a/includes/api/ApiImport.php +++ b/includes/api/ApiImport.php @@ -177,7 +177,8 @@ public function getExamples() { return array( - 'api.php?action=import&interwikisource=meta&interwikipage=Help:ParserFunctions&namespace=100&fullhistory=&token=123ABC' + 'api.php?action=import&interwikisource=meta&interwikipage=Help:ParserFunctions&' . + 'namespace=100&fullhistory=&token=123ABC' => 'Import [[meta:Help:Parserfunctions]] to namespace 100 with full history', ); } diff --git a/includes/api/ApiLogin.php b/includes/api/ApiLogin.php index 18fd0c7..fe3143e 100644 --- a/includes/api/ApiLogin.php +++ b/includes/api/ApiLogin.php @@ -132,7 +132,9 @@ $result['result'] = 'NotExists'; break; - case LoginForm::RESET_PASS: // bug 20223 - Treat a temporary password as wrong. Per SpecialUserLogin - "The e-mailed temporary password should not be used for actual logins;" + // bug 20223 - Treat a temporary password as wrong. Per SpecialUserLogin: + // The e-mailed temporary password should not be used for actual logins. + case LoginForm::RESET_PASS: case LoginForm::WRONG_PASS: $result['result'] = 'WrongPass'; break; @@ -256,24 +258,39 @@ public function getDescription() { return array( 'Log in and get the authentication tokens.', - 'In the event of a successful log-in, a cookie will be attached', - 'to your session. In the event of a failed log-in, you will not', - 'be able to attempt another log-in through this method for 5 seconds.', - 'This is to prevent password guessing by automated password crackers' + 'In the event of a successful log-in, a cookie will be attached to your session.', + 'In the event of a failed log-in, you will not be able to attempt another log-in', + 'through this method for 5 seconds. This is to prevent password guessing by', + 'automated password crackers' ); } public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( - array( 'code' => 'NeedToken', 'info' => 'You need to resubmit your login with the specified token. See https://bugzilla.wikimedia.org/show_bug.cgi?id=23076' ), + array( + 'code' => 'NeedToken', 'info' => 'You need to resubmit your ' . + 'login with the specified token. See ' . + 'https://bugzilla.wikimedia.org/show_bug.cgi?id=23076' + ), array( 'code' => 'WrongToken', 'info' => 'You specified an invalid token' ), array( 'code' => 'NoName', 'info' => 'You didn\'t set the lgname parameter' ), array( 'code' => 'Illegal', 'info' => 'You provided an illegal username' ), array( 'code' => 'NotExists', 'info' => 'The username you provided doesn\'t exist' ), - array( 'code' => 'EmptyPass', 'info' => 'You didn\'t set the lgpassword parameter or you left it empty' ), + array( + 'code' => 'EmptyPass', + 'info' => 'You didn\'t set the lgpassword parameter or you left it empty' + ), array( 'code' => 'WrongPass', 'info' => 'The password you provided is incorrect' ), - array( 'code' => 'WrongPluginPass', 'info' => 'Same as "WrongPass", returned when an authentication plugin rather than MediaWiki itself rejected the password' ), - array( 'code' => 'CreateBlocked', 'info' => 'The wiki tried to automatically create a new account for you, but your IP address has been blocked from account creation' ), + array( + 'code' => 'WrongPluginPass', + 'info' => 'Same as "WrongPass", returned when an authentication ' . + 'plugin rather than MediaWiki itself rejected the password' + ), + array( + 'code' => 'CreateBlocked', + 'info' => 'The wiki tried to automatically create a new account ' . + 'for you, but your IP address has been blocked from account creation' + ), array( 'code' => 'Throttled', 'info' => 'You\'ve logged in too many times in a short time' ), array( 'code' => 'Blocked', 'info' => 'User is blocked' ), ) ); diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index c301e9e..a6a6e08 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -110,6 +110,7 @@ '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', @@ -126,6 +127,7 @@ 'params' => array( ApiBase::LIMIT_SML2, ApiBase::LIMIT_BIG2 ) ) ); + // @codingStandardsIgnoreEnd /** * @var ApiFormatBase @@ -144,7 +146,8 @@ /** * 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 ) { @@ -459,6 +462,7 @@ } else { $origins = explode( ' ', $originHeader ); } + if ( !in_array( $originParam, $origins ) ) { // origin parameter set but incorrect // Send a 403 response @@ -469,7 +473,14 @@ 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' ); @@ -483,7 +494,8 @@ * @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 ) { @@ -650,7 +662,10 @@ '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 @@ -727,7 +742,9 @@ 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' ); } } @@ -892,7 +909,8 @@ 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]; } } @@ -1053,13 +1071,17 @@ '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.', ), ); } @@ -1073,14 +1095,14 @@ 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.', @@ -1093,13 +1115,15 @@ ' 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', '', '', '', @@ -1132,7 +1156,8 @@ ' 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-...@lists.wikimedia.org', 'or file a bug report at https://bugzilla.wikimedia.org/' @@ -1221,7 +1246,8 @@ /** * @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 ) { diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index c2d0959..5d5d1b7 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -77,7 +77,11 @@ $this->dieUsageMsg( reset( $retval ) ); } - $r = array( 'from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason'] ); + $r = array( + 'from' => $fromTitle->getPrefixedText(), + 'to' => $toTitle->getPrefixedText(), + 'reason' => $params['reason'] + ); if ( $fromTitle->exists() ) { //NOTE: we assume that if the old title exists, it's because it was re-created as @@ -232,7 +236,8 @@ 'noredirect' => 'Don\'t create a redirect', 'watch' => 'Add the page and the redirect to your watchlist', 'unwatch' => 'Remove the page and the redirect from your watchlist', - 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch', + 'watchlist' => 'Unconditionally add or remove the page from your ' . + 'watchlist, use preferences or do not change watch', 'ignorewarnings' => 'Ignore any warnings' ); } @@ -293,7 +298,8 @@ public function getExamples() { return array( - 'api.php?action=move&from=Badtitle&to=Goodtitle&token=123ABC&reason=Misspelled%20title&movetalk=&noredirect=' + 'api.php?action=move&from=Badtitle&to=Goodtitle&token=123ABC&' . + 'reason=Misspelled%20title&movetalk=&noredirect=' ); } diff --git a/includes/api/ApiOptions.php b/includes/api/ApiOptions.php index 7256066..929b0b6 100644 --- a/includes/api/ApiOptions.php +++ b/includes/api/ApiOptions.php @@ -31,7 +31,6 @@ * @ingroup API */ class ApiOptions extends ApiBase { - /** * Changes preferences of the current user. */ @@ -172,9 +171,13 @@ 'token' => 'An options token previously obtained through the action=tokens', 'reset' => 'Resets preferences to the site defaults', 'resetkinds' => 'List of types of options to reset when the "reset" option is set', - 'change' => 'List of changes, formatted name=value (e.g. skin=vector), value cannot contain pipe characters. If no value is given (not even an equals sign), e.g., optionname|otheroption|..., the option will be reset to its default value', + 'change' => 'List of changes, formatted name=value (e.g. skin=vector), ' . + 'value cannot contain pipe characters. If no value is given (not ' . + 'even an equals sign), e.g., optionname|otheroption|..., the ' . + 'option will be reset to its default value', 'optionname' => 'A name of a option which should have an optionvalue set', - 'optionvalue' => 'A value of the option specified by the optionname, can contain pipe characters', + 'optionvalue' => 'A value of the option specified by the optionname, ' . + 'can contain pipe characters', ); } @@ -182,7 +185,8 @@ return array( 'Change preferences of the current user', 'Only options which are registered in core or in one of installed extensions,', - 'or as options with keys prefixed with \'userjs-\' (intended to be used by user scripts), can be set.' + 'or as options with keys prefixed with \'userjs-\' (intended to be used by user', + 'scripts), can be set.' ); } @@ -209,7 +213,8 @@ return array( 'api.php?action=options&reset=&token=123ABC', 'api.php?action=options&change=skin=vector|hideminor=1&token=123ABC', - 'api.php?action=options&reset=&change=skin=monobook&optionname=nickname&optionvalue=[[User:Beau|Beau]]%20([[User_talk:Beau|talk]])&token=123ABC', + 'api.php?action=options&reset=&change=skin=monobook&optionname=nickname&' . + 'optionvalue=[[User:Beau|Beau]]%20([[User_talk:Beau|talk]])&token=123ABC', ); } } diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 9981ec1..8105b94 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -684,7 +684,8 @@ =>'If translations for extmetadata property are available, fetch all of them.', 'extmetadatafilter' => "If specified and non-empty, only these keys will be returned for {$p}prop=extmetadata", - 'continue' => 'If the query response includes a continue value, use it here to get another page of results', + 'continue' => 'If the query response includes a continue value, ' . + 'use it here to get another page of results', 'localonly' => 'Look only for files in the local repository', ); } -- To view, visit https://gerrit.wikimedia.org/r/95802 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I06de371393d50eada33154626874b106d814642b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Siebrand <siebr...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits