r75266 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75265‎ | r75266 | r75267 >
Date:16:41, 23 October 2010
Author:btongminh
Status:ok (Comments)
Tags:
Comment:
Added rvparse to parse revisions. For performance reasons if this option is used, rvlimit is enforced to 1.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryRevisions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryRevisions.php
@@ -161,6 +161,15 @@
162162 // Possible indexes used
163163 $index = array();
164164
 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+
165174 if ( !is_null( $this->token ) || $pageCount > 0 ) {
166175 $this->addFields( Revision::selectPageFields() );
167176 }
@@ -199,6 +208,11 @@
200209
201210 $this->expandTemplates = $params['expandtemplates'];
202211 $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+ }
203217 if ( isset( $params['section'] ) ) {
204218 $this->section = $params['section'];
205219 } else {
@@ -209,13 +223,6 @@
210224 //Bug 24166 - API error when using rvprop=tags
211225 $this->addTables( 'revision' );
212226
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 - }
220227
221228 if ( $enumRevMode ) {
222229 // This is mostly to prevent parameter errors (and optimize SQL?)
@@ -464,9 +471,32 @@
465472 $vals['parsetree'] = $xml;
466473
467474 }
468 - if ( $this->expandTemplates ) {
 475+ if ( $this->expandTemplates && !$this->parseContent ) {
469476 $text = $wgParser->preprocess( $text, $title, new ParserOptions() );
470477 }
 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+ }
471501 ApiResult::setContent( $vals, $text );
472502 } elseif ( $this->fld_content ) {
473503 $vals['texthidden'] = '';
@@ -560,6 +590,7 @@
561591 'tag' => null,
562592 'expandtemplates' => false,
563593 'generatexml' => false,
 594+ 'parse' => false,
564595 'section' => null,
565596 'token' => array(
566597 ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
@@ -597,6 +628,7 @@
598629 'excludeuser' => 'Exclude revisions made by user',
599630 'expandtemplates' => 'Expand templates in revision content',
600631 '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.',
601633 'section' => 'Only retrieve the content of this section number',
602634 'token' => 'Which tokens to obtain for each revision',
603635 'continue' => 'When more results are available, use this to continue',
Index: trunk/phase3/RELEASE-NOTES
@@ -436,6 +436,8 @@
437437 * (bug 24792) API help for action=purge sometimes wrongly stated whether a
438438 POST request was needed due to cache pollution
439439 * 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.
440442
441443 === Languages updated in 1.17 ===
442444

Follow-up revisions

RevisionCommit summaryAuthorDate
r75521Followup to r75266: remove warning "rvlimit may not be less than 1 (set to )"...catrope11:50, 27 October 2010
r89507* (bug 28897) rvparse doesn’t seem to work with rvsectionreedy16:34, 5 June 2011

Comments

#Comment by Reedy (talk | contribs)   16:15, 5 June 2011

I think this has caused (introduced the functionality) bugzilla:28897 rvparse doesn’t seem to work with rvsection

Status & tagging log