r70501 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70500‎ | r70501 | r70502 >
Date:15:24, 5 August 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Move the math option inside ParserOptions instead of having Math.php directly sneaking into $wgUser.
Throw an exception if trying to use the DateFormat ParserOption and the UseDynamicDates option is not set.
Modified paths:
  • /trunk/phase3/includes/Math.php (modified) (history)
  • /trunk/phase3/includes/parser/CoreTagHooks.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOptions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/CoreTagHooks.php
@@ -40,7 +40,7 @@
4141
4242 static function math( $content, $attributes, $parser ) {
4343 global $wgContLang;
44 - return $wgContLang->armourMath( MathRenderer::renderMath( $content, $attributes ) );
 44+ return $wgContLang->armourMath( MathRenderer::renderMath( $content, $attributes, $parser->mOptions ) );
4545 }
4646
4747 static function gallery( $content, $attributes, $parser ) {
Index: trunk/phase3/includes/parser/ParserOptions.php
@@ -54,6 +54,8 @@
5555 function getEnableLimitReport() { return $this->mEnableLimitReport; }
5656 function getCleanSignatures() { return $this->mCleanSignatures; }
5757 function getExternalLinkTarget() { return $this->mExternalLinkTarget; }
 58+ function getMath() { return $this->mMath; }
 59+
5860 function getIsPreview() { return $this->mIsPreview; }
5961 function getIsSectionPreview() { return $this->mIsSectionPreview; }
6062 function getIsPrintable() { return $this->mIsPrintable; }
@@ -66,6 +68,10 @@
6769 }
6870
6971 function getDateFormat() {
 72+ if ( !$this->getUseDynamicDates() ) {
 73+ throw new MWException( 'Getting DateFormat option without UseDynamicDates.' );
 74+ }
 75+
7076 if ( !isset( $this->mDateFormat ) ) {
7177 $this->mDateFormat = $this->mUser->getDatePreference();
7278 }
@@ -101,6 +107,8 @@
102108 function setTimestamp( $x ) { return wfSetVar( $this->mTimestamp, $x ); }
103109 function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures, $x ); }
104110 function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget, $x ); }
 111+ function setMath( $x ) { return wfSetVar( $this->mMath, $x ); }
 112+
105113 function setIsPreview( $x ) { return wfSetVar( $this->mIsPreview, $x ); }
106114 function setIsSectionPreview( $x ) { return wfSetVar( $this->mIsSectionPreview, $x ); }
107115 function setIsPrintable( $x ) { return wfSetVar( $this->mIsPrintable, $x ); }
@@ -163,6 +171,8 @@
164172 $this->mEnableLimitReport = false;
165173 $this->mCleanSignatures = $wgCleanSignatures;
166174 $this->mExternalLinkTarget = $wgExternalLinkTarget;
 175+ $this->mMath = $user->getOption( 'math' );
 176+
167177 $this->mIsPreview = false;
168178 $this->mIsSectionPreview = false;
169179 $this->mIsPrintable = false;
Index: trunk/phase3/includes/Math.php
@@ -324,10 +324,10 @@
325325 .'/'. substr($this->hash, 2, 1);
326326 }
327327
328 - public static function renderMath( $tex, $params=array() ) {
329 - global $wgUser;
 328+ public static function renderMath( $tex, $params=array(), ParserOptions $parserOptions = null ) {
330329 $math = new MathRenderer( $tex, $params );
331 - $math->setOutputMode( $wgUser->getOption('math'));
 330+ if ( $parserOptions )
 331+ $math->setOutputMode( $parserOptions->getMath() );
332332 return $math->render();
333333 }
334334 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r70533Fix failing parserTests by defineing wgUseDynamicDates=1 as required by r70501...mah00:37, 6 August 2010
r70651Revert r70533 and the piece of r70501 that it tried to fix. Note and open bug...platonides21:21, 7 August 2010
r70783Use only the page relevant pieces in the parser cache key. Eg. two users with...platonides21:53, 9 August 2010

Comments

#Comment by MarkAHershberger (talk | contribs)   00:40, 6 August 2010
+		if ( !$this->getUseDynamicDates() ) {
+			throw new MWException( 'Getting DateFormat option without UseDynamicDates.' );
+		}

Please try running the parser tests after modifying the parser.

Status & tagging log