r88780 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88779‎ | r88780 | r88781 >
Date:10:11, 25 May 2011
Author:aaron
Status:resolved (Comments)
Tags:
Comment:
* Follow-up r88740:
* Fixed parse() arguments in getRevIncludes()
* Changed clearTagHook() to avoid preprocessed-xml cache corruption
* Check current version cache in getRevIncludes()
Modified paths:
  • /trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -4531,6 +4531,7 @@
45324532
45334533 /**
45344534 * Remove a specific tag hook. Should not be called on $wgParser.
 4535+ * Does not change the strip list.
45354536 *
45364537 * @param string $tag
45374538 * @return void
@@ -4538,10 +4539,6 @@
45394540 function clearTagHook( $tag ) {
45404541 if ( isset( $this->mTagHooks[$tag] ) ) {
45414542 unset( $this->mTagHooks[$tag] );
4542 - $key = array_search( $tag, $this->mStripList );
4543 - if ( $key !== false ) {
4544 - unset( $this->mStripList[$key] );
4545 - }
45464543 }
45474544 }
45484545
Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php
@@ -601,13 +601,21 @@
602602 if ( is_array( $val ) ) {
603603 $versions = $val; // cache hit
604604 } else {
605 - $title = $article->getTitle();
606 - $pOpts = ParserOptions::newFromUser( $user ); // Note: tidy off
607 - # Disable slow crap that doesn't matter for getting templates/files...
608 - $parser = clone $wgParser;
609 - $parser->clearTagHook( 'ref' );
610 - $parser->clearTagHook( 'references' );
611 - $pOut = $parser->parse( $rev->getText(), $title, $pOpts, $rev->getId() );
 605+ $pOut = false;
 606+ if ( $rev->isCurrent() ) { // try current version parser cache
 607+ $parserCache = ParserCache::singleton();
 608+ $pOut = $parserCache->get( $article, $article->makeParserOptions( $user ) );
 609+ }
 610+ if ( $pOut == false ) {
 611+ $title = $article->getTitle();
 612+ $pOpts = ParserOptions::newFromUser( $user ); // Note: tidy off
 613+ # Disable slow crap that doesn't matter for getting templates/files...
 614+ $parser = clone $wgParser;
 615+ $parser->clearTagHook( 'ref' );
 616+ $parser->clearTagHook( 'references' );
 617+ $pOut = $parser->parse(
 618+ $rev->getText(), $title, $pOpts, true, true, $rev->getId() );
 619+ }
612620 # Get the template/file versions used...
613621 $versions = array( $pOut->getTemplateIds(), $pOut->getImageTimeKeys() );
614622 # Save to cache...

Follow-up revisions

RevisionCommit summaryAuthorDate
r96998Removed parser hacks from r88740, r88741, r88780aaron20:26, 13 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r88740* Enumerate the specific templates/files that changed on review diffs...aaron19:51, 24 May 2011

Comments

#Comment by Tim Starling (talk | contribs)   05:44, 2 September 2011

Does calling clearTagHook() like that make any difference to performance? It still has to expand the same templates, so I would have thought the parse time would be almost identical.

If there is no difference, I would suggest not using it, since you are introducing an unnecessary dependency on details of parser functionality.

#Comment by Aaron Schulz (talk | contribs)   00:24, 13 September 2011

Tagged for removed off clearTagHook().

#Comment by Dantman (talk | contribs)   20:18, 15 September 2011

Shouldn't the $rev->getText use a audience parameter?

Status & tagging log