From: Brion Vibber Date: Thu, 15 Nov 2007 02:54:28 +0000 (+0000) Subject: Fix regression in r27416 -- {{REVISIONID}} was broken on save since a parsed copy... X-Git-Tag: 1.31.0-rc.0~50869 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=b9ddd7440b1a73689984400dba42dc9de6157239;p=lhc%2Fweb%2Fwiklou.git Fix regression in r27416 -- {{REVISIONID}} was broken on save since a parsed copy from before revision-insert was used to insert into parser cache. The parser now sets a "vary-revision" flag on the ParserOutput when using {{REVISIONID}}; Article then reparses the page after insertion if and only if required. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f082afd45a..ad2cf089ff 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -20,10 +20,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN === Configuration changes in 1.12 === -=== Removed features in 1.12 === -* {{REVISIONID}} will no longer give the correct revision ID for current revision - views. It will still work for history views. - === New features in 1.12 === * (bug 10735) Add a warning for non-descriptive filenames at Special:Upload * Add {{filepath:}} parser function to get full path to an uploaded file, diff --git a/includes/Article.php b/includes/Article.php index 7f23be4fcd..76391afb56 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -2425,18 +2425,19 @@ class Article { * Prepare text which is about to be saved. * Returns a stdclass with source, pst and output members */ - function prepareTextForEdit( $text ) { - if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text ) { + function prepareTextForEdit( $text, $revid=null ) { + if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid) { // Already prepared return $this->mPreparedEdit; } global $wgParser; $edit = (object)array(); + $edit->revid = $revid; $edit->newText = $text; $edit->pst = $this->preSaveTransform( $text ); $options = new ParserOptions; $options->setTidy( true ); - $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $options, true, true ); + $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $options, true, true, $revid ); $edit->oldText = $this->getContent(); $this->mPreparedEdit = $edit; return $edit; @@ -2462,9 +2463,11 @@ class Article { # Parse the text # Be careful not to double-PST: $text is usually already PST-ed once - if ( !$this->mPreparedEdit ) { - $editInfo = $this->prepareTextForEdit( $text ); + if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) { + wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" ); + $editInfo = $this->prepareTextForEdit( $text, $newid ); } else { + wfDebug( __METHOD__ . ": No vary-revision, using prepared edit...\n" ); $editInfo = $this->mPreparedEdit; } diff --git a/includes/Parser.php b/includes/Parser.php index 3f6a3c6c5f..0ad8b82dfe 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2528,6 +2528,10 @@ class Parser $subjPage = $this->mTitle->getSubjectPage(); return $subjPage->getPrefixedUrl(); case 'revisionid': + // Let the edit saving system know we should parse the page + // *after* a revision ID has been assigned. + $this->mOutput->setFlag( 'vary-revision' ); + wfDebug( __METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n" ); return $this->mRevisionId; case 'revisionday': return intval( substr( $this->getRevisionTimestamp(), 6, 2 ) ); diff --git a/includes/ParserOutput.php b/includes/ParserOutput.php index d4daf1d177..5b795939b4 100644 --- a/includes/ParserOutput.php +++ b/includes/ParserOutput.php @@ -165,6 +165,17 @@ class ParserOutput return $this->displayTitle; } + /** + * Fairly generic flag setter thingy. + */ + public function setFlag( $flag ) { + $this->mFlags[$flag] = true; + } + + public function getFlag( $flag ) { + return isset( $this->mFlags[$flag] ); + } + }