52 parent::__construct( $main, $action );
53 $this->repoGroup = $repoGroup;
66 $sourceUrl = $this->file->getArchiveVirtualUrl( $this->archiveName );
67 $status = $this->file->upload(
69 $this->params[
'comment'],
70 $this->params[
'comment'],
77 if ( $status->isGood() ) {
78 $result = [
'result' =>
'Success' ];
81 'result' =>
'Failure',
95 $title = Title::makeTitleSafe(
NS_FILE, $this->params[
'filename'] );
101 $localRepo = $this->repoGroup->getLocalRepo();
104 $this->file = $localRepo->newFile(
$title );
105 if ( !$this->file->exists() ) {
110 $this->archiveName = $this->params[
'archivename'];
112 $oldFile = $localRepo->newFromArchiveName(
$title, $this->archiveName );
113 if ( !$oldFile->exists() ) {
129 ParamValidator::PARAM_TYPE =>
'string',
130 ParamValidator::PARAM_REQUIRED =>
true,
133 ParamValidator::PARAM_DEFAULT =>
'',
136 ParamValidator::PARAM_TYPE =>
'string',
137 ParamValidator::PARAM_REQUIRED =>
true,
148 'action=filerevert&filename=Wiki.png&comment=Revert&' .
149 'archivename=20110305152740!Wiki.png&token=123ABC'
150 =>
'apihelp-filerevert-example-revert',
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
This abstract class implements many basic API functions, and is the base of all API classes.
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
checkTitleUserPermissions( $pageIdentity, $actions, array $options=[])
Helper function for permission-denied errors.
getModuleName()
Get the name of the module being executed by this instance.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
isWriteMode()
Indicates whether this module requires write mode.
validateParameters()
Validate the user parameters and set $this->archiveName and $this->file.
__construct(ApiMain $main, $action, RepoGroup $repoGroup)
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
mustBePosted()
Indicates whether this module must be called with a POST request.
needsToken()
Returns the token type this module requires in order to execute.
getExamplesMessages()
Returns usage examples for this module.
This is the main API class, used for both external and internal processing.
Local file in the wiki's own database.
Prioritized list of file repositories.