r89176 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89175‎ | r89176 | r89177 >
Date:16:10, 30 May 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* make preprocessorFuzzTest.php pass the Title object to Parser, removed checks for non-object in Parser
* make the parser use ParserOptions::getUser() instead of $wgUser
* fixed some E_NOTICE and E_STRICT in preprocessorFuzzTest.php
Modified paths:
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/maintenance/preprocessorFuzzTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/preprocessorFuzzTest.php
@@ -190,10 +190,10 @@
191191 $wgUser->mFrom = 'name';
192192 $wgUser->ppfz_test = $this;
193193
194 - $options = new ParserOptions;
 194+ $options = ParserOptions::newFromUser( $wgUser );
195195 $options->setTemplateCallback( array( $this, 'templateHook' ) );
196196 $options->setTimestamp( wfTimestampNow() );
197 - $this->output = call_user_func( array( $wgParser, $this->entryPoint ), $this->mainText, $this->title->getPrefixedText(), $options );
 197+ $this->output = call_user_func( array( $wgParser, $this->entryPoint ), $this->mainText, $this->title, $options );
198198 return $this->output;
199199 }
200200
@@ -217,7 +217,7 @@
218218 }
219219
220220 class PPFuzzUser extends User {
221 - var $ppfz_test;
 221+ var $ppfz_test, $mDataLoaded;
222222
223223 function load() {
224224 if ( $this->mDataLoaded ) {
@@ -227,13 +227,13 @@
228228 $this->loadDefaults( $this->mName );
229229 }
230230
231 - function getOption( $option, $defaultOverride = '' ) {
 231+ function getOption( $oname, $defaultOverride = null, $ignoreHidden = false ) {
232232 if ( $option === 'fancysig' ) {
233233 return $this->ppfz_test->fancySig;
234234 } elseif ( $option === 'nickname' ) {
235235 return $this->ppfz_test->nickname;
236236 } else {
237 - return parent::getOption( $option, $defaultOverride );
 237+ return parent::getOption( $option, $defaultOverride, $ignoreHidden );
238238 }
239239 }
240240 }
Index: trunk/phase3/includes/parser/Parser.php
@@ -5461,9 +5461,6 @@
54625462 * @return string
54635463 */
54645464 function testSrvus( $text, $title, ParserOptions $options, $outputType = self::OT_HTML ) {
5465 - if ( !$title instanceof Title ) {
5466 - $title = Title::newFromText( $title );
5467 - }
54685465 $this->startParse( $title, $options, $outputType, true );
54695466
54705467 $text = $this->replaceVariables( $text );
@@ -5473,17 +5470,10 @@
54745471 }
54755472
54765473 function testPst( $text, $title, $options ) {
5477 - global $wgUser;
5478 - if ( !$title instanceof Title ) {
5479 - $title = Title::newFromText( $title );
5480 - }
5481 - return $this->preSaveTransform( $text, $title, $wgUser, $options );
 5474+ return $this->preSaveTransform( $text, $title, $options->getUser(), $options );
54825475 }
54835476
54845477 function testPreprocess( $text, $title, $options ) {
5485 - if ( !$title instanceof Title ) {
5486 - $title = Title::newFromText( $title );
5487 - }
54885478 return $this->testSrvus( $text, $title, $options, self::OT_PREPROCESS );
54895479 }
54905480

Follow-up revisions

RevisionCommit summaryAuthorDate
r90053Per Nikerabbit, fixes for r89176:...ialex15:08, 14 June 2011

Comments

#Comment by Nikerabbit (talk | contribs)   12:45, 14 June 2011
+	function getOption( $oname, $defaultOverride = null, $ignoreHidden = false ) {
 		if ( $option === 'fancysig' ) {

This doesn't look right.

Would it make sense to add Title type hint to arguments of testFoo methods?

#Comment by IAlex (talk | contribs)   15:09, 14 June 2011

Done in r90053.

Status & tagging log