X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryRevisionsBase.php;h=1805f40a2295b09e789c12b108187a3709ab3b4f;hb=fa645c842e7fdc4b0460525244a5f50ae916810f;hp=3879d7b566e52b7a810065fcc8d0e80fb37dda28;hpb=c1fab2ba1ddffd689fc99a0651c3aa8e7dc4ac60;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryRevisionsBase.php b/includes/api/ApiQueryRevisionsBase.php index 3879d7b566..1805f40a22 100644 --- a/includes/api/ApiQueryRevisionsBase.php +++ b/includes/api/ApiQueryRevisionsBase.php @@ -32,7 +32,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { protected $limit, $diffto, $difftotext, $expandTemplates, $generateXML, $section, - $parseContent, $contentFormat, $setParsedLimit = true; + $parseContent, $fetchContent, $contentFormat, $setParsedLimit = true; protected $fld_ids = false, $fld_flags = false, $fld_timestamp = false, $fld_size = false, $fld_sha1 = false, $fld_comment = false, @@ -78,7 +78,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { // DifferenceEngine returns a rather ambiguous empty // string if that's not the case if ( $params['diffto'] != 0 ) { - $difftoRev = Revision::newFromID( $params['diffto'] ); + $difftoRev = Revision::newFromId( $params['diffto'] ); if ( !$difftoRev ) { $this->dieUsageMsg( array( 'nosuchrevid', $params['diffto'] ) ); } @@ -111,8 +111,11 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { $this->limit = $params['limit']; + $this->fetchContent = $this->fld_content || !is_null( $this->diffto ) + || !is_null( $this->difftotext ); + $smallLimit = false; - if ( $this->fld_content || !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) { + if ( $this->fetchContent ) { $smallLimit = true; $this->expandTemplates = $params['expandtemplates']; $this->generateXML = $params['generatexml']; @@ -135,7 +138,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { if ( $this->limit == 'max' ) { $this->limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; if ( $this->setParsedLimit ) { - $this->getResult()->setParsedLimit( $this->getModuleName(), $this->limit ); + $this->getResult()->addParsedLimit( $this->getModuleName(), $this->limit ); } } @@ -176,9 +179,9 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { } if ( $revision->userCan( Revision::DELETED_USER, $user ) ) { if ( $this->fld_user ) { - $vals['user'] = $revision->getRawUserText(); + $vals['user'] = $revision->getUserText( Revision::RAW ); } - $userid = $revision->getRawUser(); + $userid = $revision->getUser( Revision::RAW ); if ( !$userid ) { $vals['anon'] = ''; } @@ -225,7 +228,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { $anyHidden = true; } if ( $revision->userCan( Revision::DELETED_COMMENT, $user ) ) { - $comment = $revision->getRawComment(); + $comment = $revision->getComment( Revision::RAW ); if ( $this->fld_comment ) { $vals['comment'] = $comment; @@ -240,7 +243,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { if ( $this->fld_tags ) { if ( $row->ts_tags ) { $tags = explode( ',', $row->ts_tags ); - $this->getResult()->setIndexedTagName( $tags, 'tag' ); + ApiResult::setIndexedTagName( $tags, 'tag' ); $vals['tags'] = $tags; } else { $vals['tags'] = array(); @@ -249,7 +252,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { $content = null; global $wgParser; - if ( $this->fld_content || !is_null( $this->diffto ) || !is_null( $this->difftotext ) ) { + if ( $this->fetchContent ) { $content = $revision->getContent( Revision::FOR_THIS_USER, $this->getUser() ); // Expand templates after getting section content because // template-added sections don't count and Parser::preprocess() @@ -344,7 +347,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { } if ( $text !== false ) { - ApiResult::setContent( $vals, $text ); + ApiResult::setContentValue( $vals, 'content', $text ); } } @@ -386,7 +389,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { } if ( $engine ) { $difftext = $engine->getDiffBody(); - ApiResult::setContent( $vals['diff'], $difftext ); + ApiResult::setContentValue( $vals['diff'], 'body', $difftext ); if ( !$engine->wasCacheHit() ) { $n++; }