From: Alexandre Emsenhuber Date: Mon, 14 Nov 2011 18:28:01 +0000 (+0000) Subject: Update DifferenceEngine::renderNewRevision() to run the 'ArticleViewCustom' hook... X-Git-Tag: 1.31.0-rc.0~26511 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=4124539a4d19cef57e50d03aca1dfefed48eb70c;p=lhc%2Fweb%2Fwiklou.git Update DifferenceEngine::renderNewRevision() to run the 'ArticleViewCustom' hook and create a WikiPage object and do "normal wikitext" processing only when really needed --- diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 51153433c4..a90fe764f0 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -497,15 +497,8 @@ class DifferenceEngine extends ContextSource {

{$revHeader}

\n" ); # Page content may be handled by a hooked call instead... if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $out ) ) ) { - # Use the current version parser cache if applicable - $pCache = true; - if ( !$this->mNewRev->isCurrent() ) { - $oldEditSectionSetting = $out->parserOptions()->setEditSection( false ); - $pCache = false; - } - $this->loadNewText(); - $out->setRevisionId( $this->mNewRev->getId() ); + $out->setRevisionId( $this->mNewid ); $out->setArticleFlag( true ); if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) { @@ -520,20 +513,31 @@ class DifferenceEngine extends ContextSource { $out->addHTML( htmlspecialchars( $this->mNewtext ) ); $out->addHTML( "\n\n" ); } - } elseif ( $pCache ) { - $wikipage = WikiPage::factory( $this->mNewPage ); - $pOutput = ParserCache::singleton()->get( $wikipage, $out->parserOptions() ); - if( $pOutput ) { - $out->addParserOutput( $pOutput ); + } elseif ( !wfRunHooks( 'ArticleViewCustom', array( $this->mNewtext, $this->mNewPage, $out ) ) ) { + // Handled by extension + } else { + # Use the current version parser cache if applicable + $wikiPage = WikiPage::factory( $this->mNewPage ); + $useParserCache = $wikiPage->isParserCacheUsed( $this->getUser(), $this->mNewid ); + + $parserOptions = ParserOptions::newFromContext( $this->getContext() ); + $parserOptions->enableLimitReport(); + $parserOptions->setTidy( true ); + + if ( !$this->mNewRev->isCurrent() ) { + $parserOptions->setEditSection( false ); + } + + $parserOutput = false; + if ( $useParserCache ) { + $parserOutput = ParserCache::singleton()->get( $wikiPage, $out->parserOptions() ); + } + + if( $parserOutput ) { + $out->addParserOutput( $parserOutput ); } else { $out->addWikiTextTidy( $this->mNewtext ); } - } else { - $out->addWikiTextTidy( $this->mNewtext ); - } - - if ( !$this->mNewRev->isCurrent() ) { - $out->parserOptions()->setEditSection( $oldEditSectionSetting ); } } # Add redundant patrol link on bottom...