+ // 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'
+ );
+ }
+ }
+