* (bug 1103) Fix up redirect handling for images, categories
Redirects are now followed from the top-level, outside of the Article
content loading and viewing, for clarity and consistency.
+* (bug 4104) 'OutputPageBeforeHTML' hook to postprocess article HTML on
+ page view (comes after parser cache, if used). Patch by ThomasV.
=== Caveats ===
$wcOnlySysopsCanPatrol: config setting indicating whether the user
must be a sysop to patrol the edit
+'OutputPageBeforeHTML': a page has been processed by the parser and
+the resulting HTML is about to be displayed.
+$parserOutput: the parserOutput (object) that corresponds to the page
+$text: the text that will be displayed, in HTML (string)
+
'PageRenderingHash': alter the parser cache option hash key
A parser extension which depends on user options should install
this hook and append its values to the key.
if( !$this->isCurrent() ) {
$oldEditSectionSetting = $wgOut->mParserOptions->setEditSection( false );
}
- $wgOut->addWikiText( $text );
+ # Display content and don't save to parser cache
+ $wgOut->addPrimaryWikiText( $text, $this, false );
if( !$this->isCurrent() ) {
$wgOut->mParserOptions->setEditSection( $oldEditSectionSetting );
$parserOutput = $wgParser->parse( $text, $article->mTitle,
$this->mParserOptions, true, true, $this->mRevisionId );
- if ( $article && $parserOutput->getCacheTime() != -1 ) {
+ if ( $cache && $article && $parserOutput->getCacheTime() != -1 ) {
$parserCache =& ParserCache::singleton();
$parserCache->save( $parserOutput, $article, $wgUser );
}
- $this->addParserOutput( $parserOutput );
+ $this->addParserOutputNoText( $parserOutput );
+ $text = $parserOutput->getText();
+ wfRunHooks( 'OutputPageBeforeHTML',array( &$this, &$text ) );
+ $parserOutput->setText( $text );
+ $this->addHTML( $parserOutput->getText() );
}
/**
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
$this->addCategoryLinks( $parserOutput->getCategories() );
$this->addKeywords( $parserOutput );
- $this->addHTML( $parserOutput->getText() );
+ $text = $parserOutput->getText();
+ wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
+ $this->addHTML( $text );
$t = $parserOutput->getTitleText();
if( !empty( $t ) ) {
$this->setPageTitle( $t );