Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -271,13 +271,8 @@ |
272 | 272 | wfProfileIn( __METHOD__ ); |
273 | 273 | wfProfileIn( $fname ); |
274 | 274 | |
275 | | - $this->mOptions = $options; |
276 | | - if ( $clearState ) { |
277 | | - $this->clearState(); |
278 | | - } |
| 275 | + $this->startExternalParse( $title, $options, self::OT_HTML, $clearState ); |
279 | 276 | |
280 | | - $this->setTitle( $title ); # Page title has to be set for the pre-processor |
281 | | - |
282 | 277 | $oldRevisionId = $this->mRevisionId; |
283 | 278 | $oldRevisionObject = $this->mRevisionObject; |
284 | 279 | $oldRevisionTimestamp = $this->mRevisionTimestamp; |
— | — | @@ -288,7 +283,7 @@ |
289 | 284 | $this->mRevisionTimestamp = null; |
290 | 285 | $this->mRevisionUser = null; |
291 | 286 | } |
292 | | - $this->setOutputType( self::OT_HTML ); |
| 287 | + |
293 | 288 | wfRunHooks( 'ParserBeforeStrip', array( &$this, &$text, &$this->mStripState ) ); |
294 | 289 | # No more strip! |
295 | 290 | wfRunHooks( 'ParserAfterStrip', array( &$this, &$text, &$this->mStripState ) ); |
— | — | @@ -460,10 +455,7 @@ |
461 | 456 | */ |
462 | 457 | function preprocess( $text, $title, $options, $revid = null ) { |
463 | 458 | wfProfileIn( __METHOD__ ); |
464 | | - $this->mOptions = $options; |
465 | | - $this->clearState(); |
466 | | - $this->setOutputType( self::OT_PREPROCESS ); |
467 | | - $this->setTitle( $title ); |
| 459 | + $this->startExternalParse( $title, $options, self::OT_PREPROCESS, true ); |
468 | 460 | if ( $revid !== null ) { |
469 | 461 | $this->mRevisionId = $revid; |
470 | 462 | } |
— | — | @@ -483,10 +475,7 @@ |
484 | 476 | */ |
485 | 477 | public function getPreloadText( $text, $title, $options ) { |
486 | 478 | # Parser (re)initialisation |
487 | | - $this->mOptions = $options; |
488 | | - $this->clearState(); |
489 | | - $this->setOutputType( self::OT_PLAIN ); |
490 | | - $this->setTitle( $title ); |
| 479 | + $this->startExternalParse( $title, $options, self::OT_PLAIN, true ); |
491 | 480 | |
492 | 481 | $flags = PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES; |
493 | 482 | $dom = $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION ); |
— | — | @@ -4077,15 +4066,9 @@ |
4078 | 4067 | * @return String: the altered wiki markup |
4079 | 4068 | */ |
4080 | 4069 | public function preSaveTransform( $text, Title $title, User $user, ParserOptions $options, $clearState = true ) { |
4081 | | - $this->mOptions = $options; |
4082 | | - $this->setTitle( $title ); |
| 4070 | + $this->startExternalParse( $title, $options, self::OT_WIKI, $clearState ); |
4083 | 4071 | $this->setUser( $user ); |
4084 | | - $this->setOutputType( self::OT_WIKI ); |
4085 | 4072 | |
4086 | | - if ( $clearState ) { |
4087 | | - $this->clearState(); |
4088 | | - } |
4089 | | - |
4090 | 4073 | $pairs = array( |
4091 | 4074 | "\r\n" => "\n", |
4092 | 4075 | ); |
— | — | @@ -4911,11 +4894,8 @@ |
4912 | 4895 | * for "replace", the whole page with the section replaced. |
4913 | 4896 | */ |
4914 | 4897 | private function extractSections( $text, $section, $mode, $newText='' ) { |
4915 | | - global $wgTitle; |
4916 | | - $this->mOptions = new ParserOptions; |
4917 | | - $this->clearState(); |
4918 | | - $this->setTitle( $wgTitle ); # not generally used but removes an ugly failure mode |
4919 | | - $this->setOutputType( self::OT_PLAIN ); |
| 4898 | + global $wgTitle; # not generally used but removes an ugly failure mode |
| 4899 | + $this->startExternalParse( $wgTitle, new ParserOptions, self::OT_PLAIN, true ); |
4920 | 4900 | $outText = ''; |
4921 | 4901 | $frame = $this->getPreprocessor()->newFrame(); |
4922 | 4902 | |
— | — | @@ -5203,13 +5183,11 @@ |
5204 | 5184 | * strip/replaceVariables/unstrip for preprocessor regression testing |
5205 | 5185 | */ |
5206 | 5186 | function testSrvus( $text, $title, $options, $outputType = self::OT_HTML ) { |
5207 | | - $this->mOptions = $options; |
5208 | | - $this->clearState(); |
5209 | 5187 | if ( !$title instanceof Title ) { |
5210 | 5188 | $title = Title::newFromText( $title ); |
5211 | 5189 | } |
5212 | | - $this->mTitle = $title; |
5213 | | - $this->setOutputType( $outputType ); |
| 5190 | + $this->startExternalParse( $title, $options, $outputType, true ); |
| 5191 | + |
5214 | 5192 | $text = $this->replaceVariables( $text ); |
5215 | 5193 | $text = $this->mStripState->unstripBoth( $text ); |
5216 | 5194 | $text = Sanitizer::removeHTMLtags( $text ); |