48 $sourceUrl = $this->file->getArchiveVirtualUrl( $this->archiveName );
49 $status = $this->file->upload(
51 $this->params[
'comment'],
52 $this->params[
'comment'],
59 if ( $status->isGood() ) {
60 $result = [
'result' =>
'Success' ];
63 'result' =>
'Failure',
77 $title = Title::makeTitleSafe(
NS_FILE, $this->params[
'filename'] );
83 $localRepo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
86 $this->file = $localRepo->newFile(
$title );
87 if ( !$this->file->exists() ) {
92 $this->archiveName = $this->params[
'archivename'];
93 $oldFile = $localRepo->newFromArchiveName(
$title, $this->archiveName );
94 if ( !$oldFile->exists() ) {
129 'action=filerevert&filename=Wiki.png&comment=Revert&' .
130 'archivename=20110305152740!Wiki.png&token=123ABC'
131 =>
'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.
getErrorFormatter()
Get the error formatter Stable to override.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModuleName()
Get the name of the module being executed by this instance.
checkTitleUserPermissions(LinkTarget $linkTarget, $actions, array $options=[])
Helper function for permission-denied errors.
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.
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 Stable to override.
needsToken()
Returns the token type this module requires in order to execute.
getExamplesMessages()
Returns usage examples for this module.
getUser()
Stable to override.
Class to represent a local file in the wiki's own database.