diff options
author | Alexandre Emsenhuber <ialex@users.mediawiki.org> | 2011-11-14 18:28:01 +0000 |
---|---|---|
committer | Alexandre Emsenhuber <ialex@users.mediawiki.org> | 2011-11-14 18:28:01 +0000 |
commit | 4124539a4d19cef57e50d03aca1dfefed48eb70c (patch) | |
tree | 6dc0efa7d18346e990227e290545c1cc3a8c57f8 /includes/diff | |
parent | 81be80e6accedc49dcc17638b57096c43eed9158 (diff) | |
download | mediawikicore-4124539a4d19cef57e50d03aca1dfefed48eb70c.tar.gz mediawikicore-4124539a4d19cef57e50d03aca1dfefed48eb70c.zip |
Update DifferenceEngine::renderNewRevision() to run the 'ArticleViewCustom' hook and create a WikiPage object and do "normal wikitext" processing only when really needed
Notes
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/103001
Diffstat (limited to 'includes/diff')
-rw-r--r-- | includes/diff/DifferenceEngine.php | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 51153433c474..a90fe764f0ce 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -497,15 +497,8 @@ class DifferenceEngine extends ContextSource { <h2 class='diff-currentversion-title'>{$revHeader}</h2>\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</pre>\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... |