48 self::PARAM_SOURCE =>
'path',
49 ParamValidator::PARAM_TYPE =>
'string',
50 ParamValidator::PARAM_REQUIRED =>
true,
59 if ( $contentType !==
'application/json' ) {
62 [
'content_type' => $contentType ]
68 self::PARAM_SOURCE =>
'body',
69 ParamValidator::PARAM_TYPE =>
'string',
70 ParamValidator::PARAM_REQUIRED =>
true,
73 self::PARAM_SOURCE =>
'body',
74 ParamValidator::PARAM_TYPE =>
'string',
75 ParamValidator::PARAM_REQUIRED =>
true,
78 self::PARAM_SOURCE =>
'body',
79 ParamValidator::PARAM_TYPE =>
'string',
80 ParamValidator::PARAM_REQUIRED =>
false,
83 self::PARAM_SOURCE =>
'body',
84 ParamValidator::PARAM_TYPE =>
'array',
85 ParamValidator::PARAM_REQUIRED =>
false,
88 self::PARAM_SOURCE =>
'body',
89 ParamValidator::PARAM_TYPE =>
'string',
90 ParamValidator::PARAM_REQUIRED =>
false,
91 ParamValidator::PARAM_DEFAULT =>
'',
103 $baseRevId = $body[
'latest'][
'id'] ?? 0;
105 $contentmodel = $body[
'content_model'] ?:
null;
107 if ( $contentmodel !==
null && !$this->contentHandlerFactory->isDefinedModel( $contentmodel ) ) {
109 new MessageValue(
'rest-bad-content-model', [ $contentmodel ] ), 400
118 'text' => $body[
'source'],
119 'summary' => $body[
'comment'],
123 if ( $contentmodel !==
null ) {
124 $params[
'contentmodel'] = $contentmodel;
127 if ( $baseRevId > 0 ) {
128 $params[
'baserevid'] = $baseRevId;
129 $params[
'nocreate'] =
true;
131 $params[
'createonly'] =
true;
144 if ( $code ===
'articleexists' ) {
152 if ( $code ===
'editconflict' ) {
157 parent::throwHttpExceptionForActionModuleError( $msg, $statusCode );
175 $baseRevId = $body[
'latest'][
'id'] ?? 0;
178 $baseRev = $this->revisionLookup->getRevisionById( $baseRevId );
179 $currentRev = $this->revisionLookup->getRevisionByTitle(
$title );
181 if ( !$baseRev || !$currentRev ) {
185 $baseContent = $baseRev->getContent(
187 RevisionRecord::FOR_THIS_USER,
190 $currentContent = $currentRev->getContent(
192 RevisionRecord::FOR_THIS_USER,
196 if ( !$baseContent || !$currentContent ) {
200 $model = $body[
'content_model'] ?: $baseContent->getModel();
201 $contentHandler = $this->contentHandlerFactory->getContentHandler( $model );
202 $newContent = $contentHandler->unserializeContent( $body[
'source'] );
211 $localDiff = $this->
getDiff( $baseContent, $newContent );
212 $remoteDiff = $this->
getDiff( $baseContent, $currentContent );
214 if ( !$localDiff || !$remoteDiff ) {
219 'base' => $baseRev->getId(),
220 'current' => $currentRev->getId(),
221 'local' => $localDiff,
222 'remote' => $remoteDiff,
235 if ( !is_callable( $this->jsonDiffFunction ) ) {
Do-nothing body validator.
Content object implementation for representing flat text.
getText()
Returns the text represented by this Content object, as a string.
Interface for messages with machine-readable data for use by the API.
getApiCode()
Returns a machine-readable code for use by the API.