X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiComparePages.php;h=93c35d3d236886bd1b3b5252b4b8934782ce28ab;hp=953bc10cc3e4b4ff0dd637da7b7c67a95a54a790;hb=74426f3cf796b149f1ae445e41815bbe148640b2;hpb=237d3271fd313ebe09858a5c442a91216a7b61cf diff --git a/includes/api/ApiComparePages.php b/includes/api/ApiComparePages.php index 953bc10cc3..93c35d3d23 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() ) { @@ -147,7 +167,10 @@ class ApiComparePages extends ApiBase { 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 ); } /** @@ -175,14 +198,17 @@ class ApiComparePages extends ApiBase { $rev = Revision::newFromId( $revId ); if ( !$rev ) { // Titles of deleted revisions aren't secret, per T51088 + $arQuery = Revision::getArchiveQueryInfo(); $row = $this->getDB()->selectRow( - 'archive', + $arQuery['tables'], array_merge( - Revision::selectArchiveFields(), + $arQuery['fields'], [ 'ar_namespace', 'ar_title' ] ), [ 'ar_rev_id' => $revId ], - __METHOD__ + __METHOD__, + [], + $arQuery['joins'] ); if ( $row ) { $rev = Revision::newFromArchiveRow( $row ); @@ -285,14 +311,17 @@ class ApiComparePages extends ApiBase { $rev = Revision::newFromId( $revId ); if ( !$rev && $this->getUser()->isAllowedAny( 'deletedtext', 'undelete' ) ) { // Try the 'archive' table + $arQuery = Revision::getArchiveQueryInfo(); $row = $this->getDB()->selectRow( - 'archive', + $arQuery['tables'], array_merge( - Revision::selectArchiveFields(), + $arQuery['fields'], [ 'ar_namespace', 'ar_title' ] ), [ 'ar_rev_id' => $revId ], - __METHOD__ + __METHOD__, + [], + $arQuery['joins'] ); if ( $row ) { $rev = Revision::newFromArchiveRow( $row ); @@ -368,7 +397,7 @@ class ApiComparePages extends ApiBase { 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'] ) ) { @@ -438,6 +467,7 @@ class ApiComparePages extends ApiBase { 'text' => [ ApiBase::PARAM_TYPE => 'text' ], + 'section' => null, 'pst' => false, 'contentformat' => [ ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),