Index: trunk/phase3/includes/api/ApiQueryRevisions.php |
— | — | @@ -161,6 +161,15 @@ |
162 | 162 | // Possible indexes used |
163 | 163 | $index = array(); |
164 | 164 | |
| 165 | + $userMax = ( $this->fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1 ); |
| 166 | + $botMax = ( $this->fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2 ); |
| 167 | + $limit = $params['limit']; |
| 168 | + if ( $limit == 'max' ) { |
| 169 | + $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; |
| 170 | + $this->getResult()->setParsedLimit( $this->getModuleName(), $limit ); |
| 171 | + } |
| 172 | + |
| 173 | + |
165 | 174 | if ( !is_null( $this->token ) || $pageCount > 0 ) { |
166 | 175 | $this->addFields( Revision::selectPageFields() ); |
167 | 176 | } |
— | — | @@ -199,6 +208,11 @@ |
200 | 209 | |
201 | 210 | $this->expandTemplates = $params['expandtemplates']; |
202 | 211 | $this->generateXML = $params['generatexml']; |
| 212 | + $this->parseContent = $params['parse']; |
| 213 | + if ( $this->parseContent ) { |
| 214 | + // We are only going to parse 1 revision per request |
| 215 | + $this->validateLimit( 'limit', $limit, 1, 1, 1 ); |
| 216 | + } |
203 | 217 | if ( isset( $params['section'] ) ) { |
204 | 218 | $this->section = $params['section']; |
205 | 219 | } else { |
— | — | @@ -209,13 +223,6 @@ |
210 | 224 | //Bug 24166 - API error when using rvprop=tags |
211 | 225 | $this->addTables( 'revision' ); |
212 | 226 | |
213 | | - $userMax = ( $this->fld_content ? ApiBase::LIMIT_SML1 : ApiBase::LIMIT_BIG1 ); |
214 | | - $botMax = ( $this->fld_content ? ApiBase::LIMIT_SML2 : ApiBase::LIMIT_BIG2 ); |
215 | | - $limit = $params['limit']; |
216 | | - if ( $limit == 'max' ) { |
217 | | - $limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax; |
218 | | - $this->getResult()->setParsedLimit( $this->getModuleName(), $limit ); |
219 | | - } |
220 | 227 | |
221 | 228 | if ( $enumRevMode ) { |
222 | 229 | // This is mostly to prevent parameter errors (and optimize SQL?) |
— | — | @@ -464,9 +471,32 @@ |
465 | 472 | $vals['parsetree'] = $xml; |
466 | 473 | |
467 | 474 | } |
468 | | - if ( $this->expandTemplates ) { |
| 475 | + if ( $this->expandTemplates && !$this->parseContent ) { |
469 | 476 | $text = $wgParser->preprocess( $text, $title, new ParserOptions() ); |
470 | 477 | } |
| 478 | + if ( $this->parseContent ) { |
| 479 | + global $wgEnableParserCache; |
| 480 | + |
| 481 | + $popts = new ParserOptions(); |
| 482 | + $popts->setTidy( true ); |
| 483 | + |
| 484 | + $articleObj = new Article( $title ); |
| 485 | + |
| 486 | + $p_result = false; |
| 487 | + $pcache = ParserCache::singleton(); |
| 488 | + if ( $wgEnableParserCache ) { |
| 489 | + $p_result = $pcache->get( $articleObj, $popts ); |
| 490 | + } |
| 491 | + if ( !$p_result ) { |
| 492 | + $p_result = $wgParser->parse( $text, $title, $popts ); |
| 493 | + |
| 494 | + if ( $wgEnableParserCache ) { |
| 495 | + $pcache->save( $p_result, $articleObj, $popts ); |
| 496 | + } |
| 497 | + } |
| 498 | + |
| 499 | + $text = $p_result->getText(); |
| 500 | + } |
471 | 501 | ApiResult::setContent( $vals, $text ); |
472 | 502 | } elseif ( $this->fld_content ) { |
473 | 503 | $vals['texthidden'] = ''; |
— | — | @@ -560,6 +590,7 @@ |
561 | 591 | 'tag' => null, |
562 | 592 | 'expandtemplates' => false, |
563 | 593 | 'generatexml' => false, |
| 594 | + 'parse' => false, |
564 | 595 | 'section' => null, |
565 | 596 | 'token' => array( |
566 | 597 | ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ), |
— | — | @@ -597,6 +628,7 @@ |
598 | 629 | 'excludeuser' => 'Exclude revisions made by user', |
599 | 630 | 'expandtemplates' => 'Expand templates in revision content', |
600 | 631 | 'generatexml' => 'Generate XML parse tree for revision content', |
| 632 | + 'parse' => 'Parse revision content. For performance reasons if this option is used, rvlimit is enforced to 1.', |
601 | 633 | 'section' => 'Only retrieve the content of this section number', |
602 | 634 | 'token' => 'Which tokens to obtain for each revision', |
603 | 635 | 'continue' => 'When more results are available, use this to continue', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -436,6 +436,8 @@ |
437 | 437 | * (bug 24792) API help for action=purge sometimes wrongly stated whether a |
438 | 438 | POST request was needed due to cache pollution |
439 | 439 | * Added iiprop=parsedcomment to prop=imageinfo, similar to prop=revisions |
| 440 | +* Added rvparse to parse revisions. For performance reasons if this option is |
| 441 | + used, rvlimit is enforced to 1. |
440 | 442 | |
441 | 443 | === Languages updated in 1.17 === |
442 | 444 | |