$this->dieWithError( 'apierror-baddiff' );
}
+ // Extract sections, if told to
+ if ( isset( $params['fromsection'] ) ) {
+ $fromContent = $fromContent->getSection( $params['fromsection'] );
+ if ( !$fromContent ) {
+ $this->dieWithError(
+ [ 'apierror-compare-nosuchfromsection', wfEscapeWikiText( $params['fromsection'] ) ],
+ 'nosuchfromsection'
+ );
+ }
+ }
+ if ( isset( $params['tosection'] ) ) {
+ $toContent = $toContent->getSection( $params['tosection'] );
+ if ( !$toContent ) {
+ $this->dieWithError(
+ [ 'apierror-compare-nosuchtosection', wfEscapeWikiText( $params['tosection'] ) ],
+ 'nosuchtosection'
+ );
+ }
+ }
+
// Get the diff
$context = new DerivativeContext( $this->getContext() );
if ( $relRev && $relRev->getTitle() ) {
ApiResult::setContentValue( $vals, 'body', $difftext );
}
- $this->getResult()->addValue( null, $this->getModuleName(), $vals );
+ // Diffs can be really big and there's little point in having
+ // ApiResult truncate it to an empty response since the diff is the
+ // whole reason this module exists. So pass NO_SIZE_CHECK here.
+ $this->getResult()->addValue( null, $this->getModuleName(), $vals, ApiResult::NO_SIZE_CHECK );
}
/**
if ( $rev ) {
$title = $rev->getTitle();
if ( isset( $this->props['ids'] ) ) {
- $vals["{$prefix}id"] = $title->getArticleId();
+ $vals["{$prefix}id"] = $title->getArticleID();
$vals["{$prefix}revid"] = $rev->getId();
}
if ( isset( $this->props['title'] ) ) {
'text' => [
ApiBase::PARAM_TYPE => 'text'
],
+ 'section' => null,
'pst' => false,
'contentformat' => [
ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),