r70517 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70516‎ | r70517 | r70518 >
Date:18:43, 5 August 2010
Author:platonides
Status:resolved (Comments)
Tags:
Comment:
Make intfunction go accross the ParserOptions.

Things like calling setUserLang( true ) to use the content language are unsupported and shouldn't be done.
Modified paths:
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOptions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -81,7 +81,7 @@
8282 static function intFunction( $parser, $part1 = '' /*, ... */ ) {
8383 if ( strval( $part1 ) !== '' ) {
8484 $args = array_slice( func_get_args(), 2 );
85 - $message = wfMsgGetKey( $part1, true, false, false );
 85+ $message = wfMsgGetKey( $part1, true, $parser->mOptions->getUserLang(), false );
8686 $message = wfMsgReplaceArgs( $message, $args );
8787 $message = $parser->replaceVariables( $message ); // like $wgMessageCache->transform()
8888 return $message;
Index: trunk/phase3/includes/parser/ParserOptions.php
@@ -29,6 +29,8 @@
3030 var $mEnableLimitReport; # Enable limit report in an HTML comment on output
3131 var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc.
3232 var $mExternalLinkTarget; # Target attribute for external links
 33+ var $mMath; # User math preference (as integer)
 34+ var $mUserLang; # Language code of the User language.
3335
3436 var $mUser; # Stored user object, just used to initialise the skin
3537 var $mIsPreview; # Parsing the page for a "preview" operation
@@ -85,6 +87,13 @@
8688 return $this->mTimestamp;
8789 }
8890
 91+ # You shouldn't use this. Really. $parser->getFunctionLang() is all you need.
 92+ # Using this fragments the cache and is discouraged. Yes, {{int: }} uses this,
 93+ # producing inconsistent tables (Bug 14404).
 94+ function getUserLang() {
 95+ return $this->mUserLang;
 96+ }
 97+
8998 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates, $x ); }
9099 function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic, $x ); }
91100 function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages, $x ); }
@@ -108,6 +117,7 @@
109118 function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures, $x ); }
110119 function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget, $x ); }
111120 function setMath( $x ) { return wfSetVar( $this->mMath, $x ); }
 121+ function setUserLang( $x ) { return wfSetVar( $this->mUserLang, $x ); }
112122
113123 function setIsPreview( $x ) { return wfSetVar( $this->mIsPreview, $x ); }
114124 function setIsSectionPreview( $x ) { return wfSetVar( $this->mIsSectionPreview, $x ); }
@@ -132,7 +142,7 @@
133143 global $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
134144 global $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion, $wgMaxArticleSize;
135145 global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, $wgCleanSignatures;
136 - global $wgExternalLinkTarget;
 146+ global $wgExternalLinkTarget, $wgLang;
137147
138148 wfProfileIn( __METHOD__ );
139149
@@ -172,6 +182,7 @@
173183 $this->mCleanSignatures = $wgCleanSignatures;
174184 $this->mExternalLinkTarget = $wgExternalLinkTarget;
175185 $this->mMath = $user->getOption( 'math' );
 186+ $this->mUserLang = $wgLang->getCode();
176187
177188 $this->mIsPreview = false;
178189 $this->mIsSectionPreview = false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r70783Use only the page relevant pieces in the parser cache key. Eg. two users with...platonides21:53, 9 August 2010
r73960fixing per comments at r70517kaldari17:25, 29 September 2010

Comments

#Comment by Ryan Kaldari (WMF) (talk | contribs)   00:51, 21 September 2010

The fix for Bug 25031 depends on this revision. Anyone want to review?

#Comment by Catrope (talk | contribs)   17:34, 23 September 2010
+	# You shouldn't use this. Really. $parser->getFunctionLang() is all you need.
+	# Using this fragments the cache and is discouraged. Yes, {{int: }} uses this,
+	# producing inconsistent tables ([https://bugzilla.wikimedia.org/show_bug.cgi?id=14404 Bug 14404]).

Use a Javadoc/Doxygen-style comment here so it'll show up in the generated docs.

#Comment by Catrope (talk | contribs)   17:35, 23 September 2010
+			$message = wfMsgGetKey( $part1, true, $parser->mOptions->getUserLang(), false );

Don't use a member directly like that, use a getter.

#Comment by Platonides (talk | contribs)   17:28, 29 September 2010

I didn't notice that it had a getter. Not all of the parser members have — and they are used from the outside :(

Kaldari fixed both issues in r73960.

Status & tagging log