r103001 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103000‎ | r103001 | r103002 >
Date:18:28, 14 November 2011
Author:ialex
Status:resolved
Tags:
Comment:
Update DifferenceEngine::renderNewRevision() to run the 'ArticleViewCustom' hook and create a WikiPage object and do "normal wikitext" processing only when really needed
Modified paths:
  • /trunk/phase3/includes/diff/DifferenceEngine.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/diff/DifferenceEngine.php
@@ -497,15 +497,8 @@
498498 <h2 class='diff-currentversion-title'>{$revHeader}</h2>\n" );
499499 # Page content may be handled by a hooked call instead...
500500 if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $out ) ) ) {
501 - # Use the current version parser cache if applicable
502 - $pCache = true;
503 - if ( !$this->mNewRev->isCurrent() ) {
504 - $oldEditSectionSetting = $out->parserOptions()->setEditSection( false );
505 - $pCache = false;
506 - }
507 -
508501 $this->loadNewText();
509 - $out->setRevisionId( $this->mNewRev->getId() );
 502+ $out->setRevisionId( $this->mNewid );
510503 $out->setArticleFlag( true );
511504
512505 if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) {
@@ -520,21 +513,32 @@
521514 $out->addHTML( htmlspecialchars( $this->mNewtext ) );
522515 $out->addHTML( "\n</pre>\n" );
523516 }
524 - } elseif ( $pCache ) {
525 - $wikipage = WikiPage::factory( $this->mNewPage );
526 - $pOutput = ParserCache::singleton()->get( $wikipage, $out->parserOptions() );
527 - if( $pOutput ) {
528 - $out->addParserOutput( $pOutput );
 517+ } elseif ( !wfRunHooks( 'ArticleViewCustom', array( $this->mNewtext, $this->mNewPage, $out ) ) ) {
 518+ // Handled by extension
 519+ } else {
 520+ # Use the current version parser cache if applicable
 521+ $wikiPage = WikiPage::factory( $this->mNewPage );
 522+ $useParserCache = $wikiPage->isParserCacheUsed( $this->getUser(), $this->mNewid );
 523+
 524+ $parserOptions = ParserOptions::newFromContext( $this->getContext() );
 525+ $parserOptions->enableLimitReport();
 526+ $parserOptions->setTidy( true );
 527+
 528+ if ( !$this->mNewRev->isCurrent() ) {
 529+ $parserOptions->setEditSection( false );
 530+ }
 531+
 532+ $parserOutput = false;
 533+ if ( $useParserCache ) {
 534+ $parserOutput = ParserCache::singleton()->get( $wikiPage, $out->parserOptions() );
 535+ }
 536+
 537+ if( $parserOutput ) {
 538+ $out->addParserOutput( $parserOutput );
529539 } else {
530540 $out->addWikiTextTidy( $this->mNewtext );
531541 }
532 - } else {
533 - $out->addWikiTextTidy( $this->mNewtext );
534542 }
535 -
536 - if ( !$this->mNewRev->isCurrent() ) {
537 - $out->parserOptions()->setEditSection( $oldEditSectionSetting );
538 - }
539543 }
540544 # Add redundant patrol link on bottom...
541545 $out->addHTML( $this->markPatrolledLink() );

Follow-up revisions

RevisionCommit summaryAuthorDate
r103002Fix for r103001: using the object is actually a good ideaialex18:31, 14 November 2011

Status & tagging log