r62860 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62859‎ | r62860 | r62861 >
Date:00:28, 23 February 2010
Author:conrad
Status:deferred
Tags:
Comment:
Tidy the state initialization in Parser::extractSections() to make it clearer
what is actually happening. Fixes bug 22602 - stops overloading OT_WIKI.
Modified paths:
  • /branches/conrad/phase3/includes/Defines.php (modified) (history)
  • /branches/conrad/phase3/includes/parser/Parser.php (modified) (history)

Diff [purge]

Index: branches/conrad/phase3/includes/Defines.php
@@ -209,6 +209,8 @@
210210 define( 'OT_WIKI', 2 );
211211 define( 'OT_PREPROCESS', 3 );
212212 define( 'OT_MSG' , 3 ); // b/c alias for OT_PREPROCESS
 213+define( 'OT_INCLUDES', 4);
 214+define( 'OT_EXTRACT', 5);
213215
214216 # Flags for Parser::setFunctionHook
215217 define( 'SFH_NO_HASH', 1 );
Index: branches/conrad/phase3/includes/parser/Parser.php
@@ -80,12 +80,14 @@
8181
8282 // Allowed values for $this->mOutputType
8383 // Parameter to startExternalParse().
84 - const OT_HTML = 1;
85 - const OT_WIKI = 2;
86 - const OT_PREPROCESS = 3;
 84+ const OT_HTML = 1; // like parse()
 85+ const OT_WIKI = 2; // like preSaveTransform()
 86+ const OT_PREPROCESS = 3; // like preprocess()
8787 const OT_MSG = 3;
88 - const OT_INCLUDES = 4;
8988
 89+ const OT_INCLUDES = 4; // like getTransclusionText() - actually a NO-OP all features use the preprocessor flags
 90+ const OT_EXTRACT = 5; // like extractSections() - should behaviour be needed later on, these flags will then work.
 91+
9092 // Marker Suffix needs to be accessible staticly.
9193 const MARKER_SUFFIX = "-QINU\x7f";
9294
@@ -4804,11 +4806,10 @@
48054807 * for "replace", the whole page with the section replaced.
48064808 */
48074809 private function extractSections( $text, $section, $mode, $newText='' ) {
4808 - global $wgTitle;
48094810 $this->clearState();
4810 - $this->setTitle( $wgTitle ); // not generally used but removes an ugly failure mode
 4811+ $this->setTitle( new FakeTitle );
48114812 $this->mOptions = new ParserOptions;
4812 - $this->setOutputType( self::OT_WIKI );
 4813+ $this->setOutputType( self::OT_EXTRACT );
48134814 $outText = '';
48144815 $frame = $this->getPreprocessor()->newFrame();
48154816

Status & tagging log