r27511 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r27510‎ | r27511 | r27512 >
Date:02:54, 15 November 2007
Author:brion
Status:old
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/includes/ParserOutput.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ParserOutput.php
@@ -165,6 +165,17 @@
166166 return $this->displayTitle;
167167 }
168168
 169+ /**
 170+ * Fairly generic flag setter thingy.
 171+ */
 172+ public function setFlag( $flag ) {
 173+ $this->mFlags[$flag] = true;
 174+ }
 175+
 176+ public function getFlag( $flag ) {
 177+ return isset( $this->mFlags[$flag] );
 178+ }
 179+
169180 }
170181
171182
Index: trunk/phase3/includes/Article.php
@@ -2425,18 +2425,19 @@
24262426 * Prepare text which is about to be saved.
24272427 * Returns a stdclass with source, pst and output members
24282428 */
2429 - function prepareTextForEdit( $text ) {
2430 - if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text ) {
 2429+ function prepareTextForEdit( $text, $revid=null ) {
 2430+ if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid) {
24312431 // Already prepared
24322432 return $this->mPreparedEdit;
24332433 }
24342434 global $wgParser;
24352435 $edit = (object)array();
 2436+ $edit->revid = $revid;
24362437 $edit->newText = $text;
24372438 $edit->pst = $this->preSaveTransform( $text );
24382439 $options = new ParserOptions;
24392440 $options->setTidy( true );
2440 - $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $options, true, true );
 2441+ $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $options, true, true, $revid );
24412442 $edit->oldText = $this->getContent();
24422443 $this->mPreparedEdit = $edit;
24432444 return $edit;
@@ -2462,9 +2463,11 @@
24632464
24642465 # Parse the text
24652466 # Be careful not to double-PST: $text is usually already PST-ed once
2466 - if ( !$this->mPreparedEdit ) {
2467 - $editInfo = $this->prepareTextForEdit( $text );
 2467+ if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) {
 2468+ wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" );
 2469+ $editInfo = $this->prepareTextForEdit( $text, $newid );
24682470 } else {
 2471+ wfDebug( __METHOD__ . ": No vary-revision, using prepared edit...\n" );
24692472 $editInfo = $this->mPreparedEdit;
24702473 }
24712474
Index: trunk/phase3/includes/Parser.php
@@ -2528,6 +2528,10 @@
25292529 $subjPage = $this->mTitle->getSubjectPage();
25302530 return $subjPage->getPrefixedUrl();
25312531 case 'revisionid':
 2532+ // Let the edit saving system know we should parse the page
 2533+ // *after* a revision ID has been assigned.
 2534+ $this->mOutput->setFlag( 'vary-revision' );
 2535+ wfDebug( __METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n" );
25322536 return $this->mRevisionId;
25332537 case 'revisionday':
25342538 return intval( substr( $this->getRevisionTimestamp(), 6, 2 ) );
Index: trunk/phase3/RELEASE-NOTES
@@ -20,10 +20,6 @@
2121
2222 === Configuration changes in 1.12 ===
2323
24 -=== Removed features in 1.12 ===
25 -* {{REVISIONID}} will no longer give the correct revision ID for current revision
26 - views. It will still work for history views.
27 -
2824 === New features in 1.12 ===
2925 * (bug 10735) Add a warning for non-descriptive filenames at Special:Upload
3026 * Add {{filepath:}} parser function to get full path to an uploaded file,

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r27416Added EditFilterMerged hook: like EditFilter but uses the text after section ...tstarling07:30, 12 November 2007

Status & tagging log