12use MediaWiki\Rest\TokenAwareHandlerTrait;
62 parent::validate( $restValidator );
70 if ( isset( $data[
'error'] ) ) {
74 if ( !isset( $data[
'edit'] ) || !$data[
'edit'][
'result'] ) {
75 throw new RuntimeException(
'Bad result structure received from ApiEditPage' );
78 if ( $data[
'edit'][
'result'] !==
'Success' ) {
82 new MessageValue(
"rest-edit-conflict", [ $data[
'edit'][
'result'] ] ),
87 $title = $this->titleParser->parseTitle( $data[
'edit'][
'title'] );
91 $revision = $this->revisionLookup->getRevisionById( (
int)$data[
'edit'][
'newrevid'] );
92 $content = $revision->getContent( SlotRecord::MAIN );
95 'id' => $data[
'edit'][
'pageid'],
96 'title' => $this->titleFormatter->getPrefixedText( $title ),
97 'key' => $this->titleFormatter->getPrefixedDBkey( $title ),
99 'id' => $data[
'edit'][
'newrevid'],
100 'timestamp' => $data[
'edit'][
'newtimestamp'],
106 'content_model' => $data[
'edit'][
'contentmodel'],
107 'source' => $content->serialize(),
117 if ( $code ===
'protectedpage' ) {
121 if ( $code ===
'badtoken' ) {
125 if ( $code ===
'missingtitle' ) {
129 if ( $code ===
'articleexists' ) {
133 if ( $code ===
'editconflict' ) {
137 if ( $code ===
'ratelimited' ) {
142 parent::throwHttpExceptionForActionModuleError( $msg, $statusCode );
147 array $actionModuleResult,
150 parent::mapActionModuleResponse(
151 $actionModuleResponse,
156 if ( $actionModuleResult[
'edit'][
'new'] ??
false ) {
A class containing constants representing the names of configuration variables.
const RightsText
Name constant for the RightsText setting, for use with Config::get()
const RightsUrl
Name constant for the RightsUrl setting, for use with Config::get()