a page
* Support <includeonly> in templates loaded through preload= parameter
* Fix ulimit parameters for wfShellExec when memory_limit is specified in 'm'
+* (bug 3979) Save correct {{REVISIONID}} into parser cache on edit
+* Substitute {{REVISIONID}} correctly in diff display
=== Caveats ===
$skin = $wgUser->getSkin();
} else if ( $pcache ) {
# Display content and save to parser cache
+ $wgOut->setRevisionId( $this->getRevIdFetched() );
$wgOut->addPrimaryWikiText( $text, $this );
} else {
# Display content, don't attempt to save to parser cache
if( !$this->isCurrent() ) {
$oldEditSectionSetting = $wgOut->mParserOptions->setEditSection( false );
}
+ $wgOut->setRevisionId( $this->getRevIdFetched() );
$wgOut->addWikiText( $text );
if( !$this->isCurrent() ) {
$this->editUpdates( $text, $summary, $isminor, $now );
$oldid = 0; # new article
- $this->showArticle( $text, wfMsg( 'newarticle' ), false, $isminor, $now, $summary, $oldid );
+ $this->showArticle( $text, wfMsg( 'newarticle' ), false, $isminor, $now, $summary, $oldid, $revisionId );
wfRunHooks( 'ArticleSaveComplete', array( &$this, &$wgUser, $text,
$summary, $isminor,
@unlink($cm->fileCacheName());
}
- $this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $isminor, $now, $summary, $lastRevision );
+ $this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $isminor, $now, $summary, $lastRevision, $revisionId );
}
wfRunHooks( 'ArticleSaveComplete',
array( &$this, &$wgUser, $text,
* After we've either updated or inserted the article, update
* the link tables and redirect to the new page.
*/
- function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid ) {
+ function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid, $newid ) {
global $wgUseDumbLinkUpdate, $wgAntiLockFlags, $wgOut, $wgUser, $wgLinkCache, $wgEnotif;
global $wgUseEnotif;
# Parse the text and save it to the parser cache
$wgOut = new OutputPage();
$wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
+ $wgOut->setRevisionId( $newid );
$wgOut->addPrimaryWikiText( $text, $this );
if ( !$wgUseDumbLinkUpdate ) {
}
$this->loadNewText();
+ if( is_object( $this->mNewRev ) ) {
+ $wgOut->setRevisionId( $this->mNewRev->getId() );
+ }
$wgOut->addWikiText( $this->mNewtext );
if( !$this->mNewRev->isCurrent() ) {
# Show current revision
#
$wgOut->addHTML( "<hr /><h2>{$this->mPagetitle}</h2>\n" );
+ if( is_object( $this->mNewRev ) ) {
+ $wgOut->setRevisionId( $this->mNewRev->getId() );
+ }
$wgOut->addWikiText( $this->mNewtext );
wfProfileOut( $fname );
$this->mSquidMaxage = 0;
$this->mScripts = '';
$this->mETag = false;
+ $this->mRevisionId = null;
}
function addHeader( $name, $val ) { array_push( $this->mHeaders, $name.': '.$val ) ; }
function setParserOptions( $options ) {
return wfSetVar( $this->mParserOptions, $options );
}
+
+ /**
+ * Set the revision ID which will be seen by the wiki text parser
+ * for things such as embedded {{REVISIONID}} variable use.
+ * @param mixed $revid an integer, or NULL
+ * @return mixed previous value
+ */
+ function setRevisionId( $revid ) {
+ $val = is_null( $revid ) ? null : intval( $revid );
+ return wfSetVar( $this->mRevisionId, $val );
+ }
/**
* Convert wikitext to HTML and add it to the buffer
function addWikiTextTitle($text, &$title, $linestart) {
global $wgParser, $wgUseTidy;
- $parserOutput = $wgParser->parse( $text, $title, $this->mParserOptions, $linestart );
+ $parserOutput = $wgParser->parse( $text, $title, $this->mParserOptions,
+ $linestart, true, $this->mRevisionId );
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
$this->mCategoryLinks += $parserOutput->getCategoryLinks();
if ( $parserOutput->getCacheTime() == -1 ) {
function addPrimaryWikiText( $text, $cacheArticle ) {
global $wgParser, $wgParserCache, $wgUser, $wgUseTidy;
- $parserOutput = $wgParser->parse( $text, $cacheArticle->mTitle, $this->mParserOptions, true );
+ $parserOutput = $wgParser->parse( $text, $cacheArticle->mTitle,
+ $this->mParserOptions, true, true, $this->mRevisionId );
$text = $parserOutput->getText();
*/
function parse( $text, $linestart = true ) {
global $wgParser, $wgTitle;
- $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions, $linestart );
+ $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions,
+ $linestart, true, $this->mRevision );
return $parserOutput->getText();
}
'texts' => array(),
'titles' => array()
);
+ $this->mRevisionId = null;
}
/**
* @param array $options
* @param boolean $linestart
* @param boolean $clearState
+ * @param int $revid number to pass in {{REVISIONID}}
* @return ParserOutput a ParserOutput
*/
- function parse( $text, &$title, $options, $linestart = true, $clearState = true ) {
+ function parse( $text, &$title, $options, $linestart = true, $clearState = true, $revid = null ) {
global $wgUseTidy, $wgContLang;
$fname = 'Parser::parse';
wfProfileIn( $fname );
$this->mOptions = $options;
$this->mTitle =& $title;
+ $this->mRevisionId = $revid;
$this->mOutputType = OT_HTML;
$this->mStripState = NULL;
* @access private
*/
function getVariableValue( $index ) {
- global $wgContLang, $wgSitename, $wgServer, $wgServerName, $wgArticle, $wgScriptPath;
+ global $wgContLang, $wgSitename, $wgServer, $wgServerName, $wgScriptPath;
/**
* Some of these require message or data lookups and can be
$ts = time();
wfRunHooks( 'ParserGetVariableValueTs', array( &$this, &$ts ) );
- $revid = $wgArticle->getRevIdFetched();
- wfRunHooks( 'ParserGetVariableValueRevid', array( &$this, &$revid ) );
switch ( $index ) {
case MAG_CURRENTMONTH:
case MAG_FULLPAGENAMEE:
return wfUrlencode( $this->mTitle->getPrefixedText() );
case MAG_REVISIONID:
- return $revid;
+ return $this->mRevisionId;
case MAG_NAMESPACE:
return $wgContLang->getNsText( $this->mTitle->getNamespace() );
case MAG_NAMESPACEE: