From: jenkins-bot Date: Mon, 18 Nov 2013 18:28:22 +0000 (+0000) Subject: Merge "Address errors and warnings in CodeSniffer in api/" X-Git-Tag: 1.31.0-rc.0~18064 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%29%20.%20%22?a=commitdiff_plain;h=0fe5700a8a2cb8805d5e4c71fcff3e36e42807e2;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "Address errors and warnings in CodeSniffer in api/" --- 0fe5700a8a2cb8805d5e4c71fcff3e36e42807e2 diff --combined includes/api/ApiDelete.php index fe5a196902,b9b07d149b..c09cad322b --- a/includes/api/ApiDelete.php +++ b/includes/api/ApiDelete.php @@@ -31,7 -31,6 +31,6 @@@ * @ingroup API */ class ApiDelete extends ApiBase { - /** * Extracts the title, token, and reason from the request parameters and invokes * the local delete() function with these as arguments. It does not make use of @@@ -52,7 -51,14 +51,14 @@@ $user = $this->getUser(); if ( $titleObj->getNamespace() == NS_FILE ) { - $status = self::deleteFile( $pageObj, $user, $params['token'], $params['oldimage'], $reason, false ); + $status = self::deleteFile( + $pageObj, + $user, + $params['token'], + $params['oldimage'], + $reason, + false + ); } else { $status = self::delete( $pageObj, $user, $params['token'], $reason ); } @@@ -127,15 -133,17 +133,17 @@@ } /** - * @param $page WikiPage|Page object to work on - * @param $user User doing the action - * @param $token - * @param $oldimage - * @param $reason - * @param $suppress bool + * @param Page $page Object to work on + * @param User $user User doing the action + * @param string $token Delete token (same as edit token) + * @param string $oldimage Archive name + * @param string $reason Reason for the deletion. Autogenerated if null. + * @param bool $suppress Whether to mark all deleted versions as restricted * @return Status|array */ - public static function deleteFile( Page $page, User $user, $token, $oldimage, &$reason = null, $suppress = false ) { + public static function deleteFile( Page $page, User $user, $token, $oldimage, + &$reason = null, $suppress = false + ) { $title = $page->getTitle(); $errors = self::getPermissionsError( $title, $user, $token ); if ( count( $errors ) ) { @@@ -211,9 -219,11 +219,11 @@@ 'title' => "Title of the page you want to delete. Cannot be used together with {$p}pageid", 'pageid' => "Page ID of the page you want to delete. Cannot be used together with {$p}title", 'token' => 'A delete token previously retrieved through prop=info', - 'reason' => 'Reason for the deletion. If not set, an automatically generated reason will be used', + 'reason' + => 'Reason for the deletion. If not set, an automatically generated reason will be used', 'watch' => 'Add the page to 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', 'unwatch' => 'Remove the page from your watchlist', 'oldimage' => 'The name of the old image to delete as provided by iiprop=archivename' ); @@@ -258,7 -268,8 +268,8 @@@ public function getExamples() { return array( 'api.php?action=delete&title=Main%20Page&token=123ABC' => 'Delete the Main Page', - 'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move' => 'Delete the Main Page with the reason "Preparing for move"', + 'api.php?action=delete&title=Main%20Page&token=123ABC&reason=Preparing%20for%20move' + => 'Delete the Main Page with the reason "Preparing for move"', ); } diff --combined includes/api/ApiMain.php index 9b099569f6,a6a6e08b49..9ecae8d0a8 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@@ -110,6 -110,7 +110,7 @@@ class ApiMain extends ApiBase '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 +127,7 @@@ 'params' => array( ApiBase::LIMIT_SML2, ApiBase::LIMIT_BIG2 ) ) ); + // @codingStandardsIgnoreEnd /** * @var ApiFormatBase @@@ -144,7 -146,8 +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 +462,7 @@@ } else { $origins = explode( ' ', $originHeader ); } + if ( !in_array( $originParam, $origins ) ) { // origin parameter set but incorrect // Send a 403 response @@@ -469,7 -473,14 +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 +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 +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 +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' ); } } @@@ -858,7 -875,7 +875,7 @@@ /** * Log the preceding request - * @param $time Time in seconds + * @param int $time Time in seconds */ protected function logRequest( $time ) { $request = $this->getRequest(); @@@ -892,7 -909,8 +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 +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 +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 +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 +1156,8 @@@ ' Victor Vasiliev - vasilvv @ gmail . com', ' Bryan Tong Minh - bryan . tongminh @ gmail . com', ' Sam Reed - sam @ reedyboy . net', - ' Yuri Astrakhan "@gmail.com" (creator, lead developer Sep 2006-Sep 2007, 2012-present)', + ' Yuri Astrakhan "@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/' @@@ -1221,7 -1246,8 +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 --combined includes/api/ApiQueryImageInfo.php index 91a9a7d59c,8105b94803..86cba83066 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@@ -310,7 -310,7 +310,7 @@@ class ApiQueryImageInfo extends ApiQuer * @param array $prop of properties to get (in the keys) * @param $result ApiResult object * @param array $thumbParams containing 'width' and 'height' items, or null - * @param string|array $metadataOpts Options for metadata fetching. + * @param array|bool|string $metadataOpts Options for metadata fetching. * This is an array consisting of the keys: * 'version': The metadata version for the metadata option * 'language': The language for extmetadata property @@@ -684,7 -684,8 +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', ); }