X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=blobdiff_plain;f=includes%2Fapi%2FApiComparePages.php;h=54865948a88d2a2d585850872520a4072198b206;hb=b7f75836ee234a0cd95b014b65ae9408e3e29251;hp=eb67babf2ad79fb876568e0b3b78970ccd69dcbb;hpb=587d08c5a626f8195def9f82ee83e17c85824db8;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiComparePages.php b/includes/api/ApiComparePages.php index eb67babf2a..54865948a8 100644 --- a/includes/api/ApiComparePages.php +++ b/includes/api/ApiComparePages.php @@ -94,6 +94,26 @@ class ApiComparePages extends ApiBase { $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() ) { @@ -444,6 +464,7 @@ class ApiComparePages extends ApiBase { 'text' => [ ApiBase::PARAM_TYPE => 'text' ], + 'section' => null, 'pst' => false, 'contentformat' => [ ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),