50 $this->user = RequestContext::getMain()->getUser();
57 if ( $fromRev->getPageId() !== $toRev->getPageId() ) {
62 if ( !$this->permissionManager->userCan(
'read', $this->user,
63 $toRev->getPageAsLinkTarget() )
66 new MessageValue(
'rest-compare-permission-denied' ), 403 );
71 'id' => $fromRev->getId(),
72 'slot_role' => $this->
getRole(),
76 'id' => $toRev->getId(),
77 'slot_role' => $this->
getRole(),
80 'diff' => [
'PLACEHOLDER' => null ]
83 $wrapperJson = $rf->encodeJson( $data );
85 $response = $rf->create();
86 $response->setHeader(
'Content-Type',
'application/json' );
88 $innerDiff = substr( $diff, 1, -1 );
90 str_replace(
'"diff":{"PLACEHOLDER":null}', $innerDiff, $wrapperJson ) ) );
99 if ( !isset( $this->revisions[$paramName] ) ) {
100 $this->revisions[$paramName] =
103 return $this->revisions[$paramName];
115 new MessageValue(
'rest-compare-nonexistent', [ $paramName ] ), 404 );
120 new MessageValue(
'rest-compare-inaccessible', [ $paramName ] ), 403 );
130 return $rev->audienceCan(
131 RevisionRecord::DELETED_TEXT,
132 RevisionRecord::FOR_THIS_USER,
138 return SlotRecord::MAIN;
142 if ( !isset( $this->textCache[$paramName] ) ) {
146 ->getSlot( $this->
getRole(), RevisionRecord::FOR_THIS_USER, $this->user )
150 $this->textCache[$paramName] =
$content->getText();
154 'rest-compare-wrong-content',
155 [ $this->
getRole(), $paramName ]
161 new MessageValue(
'rest-compare-inaccessible', [ $paramName ] ), 403 );
164 new MessageValue(
'rest-compare-nonexistent', [ $paramName ] ), 404 );
167 return $this->textCache[$paramName];
178 if ( !function_exists(
'wikidiff2_inline_json_diff' ) ) {
182 return wikidiff2_inline_json_diff( $fromText, $toText, 2 );
191 $parserSections = $this->parser->getFlatSectionInfo( $text );
193 foreach ( $parserSections as $i => $parserSection ) {
198 'level' => $parserSection[
'level'],
199 'heading' => $parserSection[
'heading'],
200 'offset' => $parserSection[
'offset'],
210 ParamValidator::PARAM_TYPE =>
'integer',
211 ParamValidator::PARAM_REQUIRED =>
true,
215 ParamValidator::PARAM_TYPE =>
'integer',
216 ParamValidator::PARAM_REQUIRED =>
true,
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Group all the pieces relevant to the context of a request into one instance @newable.
Content object implementation for representing flat text.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...