* @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
$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 );
}
}
/**
- * @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 ) ) {
'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'
);
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"',
);
}
'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' );
}
}
/**
* Log the preceding request
- * @param $time Time in seconds
+ * @param int $time Time in seconds
*/
protected function logRequest( $time ) {
$request = $this->getRequest();
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 ) {