Go to the documentation of this file.
48 if ( $user->isBot() ) {
52 $editStash = MediaWikiServices::getInstance()->getPageEditStash();
54 $title = $page->getTitle();
57 ->isSupportedFormat( $params[
'contentformat'] )
60 [
'apierror-badformat-generic', $params[
'contentformat'], $params[
'contentmodel'] ],
69 if ( $params[
'stashedtexthash'] !==
null ) {
71 $textHash = $params[
'stashedtexthash'];
72 if ( !preg_match(
'/^[0-9a-f]{40}$/', $textHash ) ) {
73 $this->
dieWithError(
'apierror-stashedit-missingtext',
'missingtext' );
75 $text = $editStash->fetchInputText( $textHash );
76 if ( !is_string( $text ) ) {
77 $this->
dieWithError(
'apierror-stashedit-missingtext',
'missingtext' );
82 $text = rtrim( str_replace(
"\r\n",
"\n", $params[
'text'] ) );
83 $textHash = sha1( $text );
87 $text,
$title, $params[
'contentmodel'], $params[
'contentformat'] );
90 if ( $page->exists() ) {
94 $this->
dieWithError( [
'apierror-nosuchrevid', $params[
'baserevid'] ] );
96 $currentRev = $page->getRevision();
98 $this->
dieWithError( [
'apierror-missingrev-pageid', $page->getId() ],
'missingrev' );
101 $editContent = $page->replaceSectionAtRev(
104 $params[
'sectiontitle'],
107 if ( !$editContent ) {
108 $this->
dieWithError(
'apierror-sectionreplacefailed',
'replacefailed' );
110 if ( $currentRev->getId() == $baseRev->getId() ) {
115 $baseContent = $baseRev->getContent();
116 $currentContent = $currentRev->getContent();
117 if ( !$baseContent || !$currentContent ) {
118 $this->
dieWithError( [
'apierror-missingcontent-pageid', $page->getId() ],
'missingrev' );
121 $content = $handler->merge3( $baseContent, $editContent, $currentContent );
134 if ( $user->pingLimiter(
'stashedit' ) ) {
137 $status = $editStash->parseAndCache( $page,
$content, $user, $params[
'summary'] );
138 $editStash->stashInputText( $text, $textHash );
141 $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
142 $stats->increment(
"editstash.cache_stores.$status" );
144 $ret = [
'status' =>
$status ];
146 if (
$status !==
'ratelimited' || $params[
'stashedtexthash'] !==
null ) {
147 $ret[
'texthash'] = $textHash;
163 $editStash = MediaWikiServices::getInstance()->getPageEditStash();
165 return $editStash->parseAndCache( $page,
$content, $user, $summary );
184 'stashedtexthash' => [
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
static getAllContentFormats()
needsToken()
Returns the token type this module requires in order to execute.
const PARAM_REQUIRED
(boolean) Is the parameter required?
isWriteMode()
Indicates whether this module requires write mode.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
getTitleOrPageId( $params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
Class representing a MediaWiki article and history.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
static newFromPageId( $pageId, $revId=0, $flags=0)
Load either the current, or a specified, revision that's attached to a given page ID.
This abstract class implements many basic API functions, and is the base of all API classes.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Class for managing stashed edits used by the page updater classes.
static getContentModels()
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
isInternal()
Indicates whether this module is "internal" Internal API modules are not (yet) intended for 3rd party...
parseAndStash(WikiPage $page, Content $content, User $user, $summary)
requireOnlyOneParameter( $params, $required)
Die if none or more than one of a certain set of parameters is set and not false.
Base interface for content objects.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
getModuleName()
Get the name of the module being executed by this instance.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Prepare an edit in shared cache so that it can be reused on edit.
mustBePosted()
Indicates whether this module must be called with a POST request.