r16858 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r16857‎ | r16858 | r16859 >
Date:13:00, 8 October 2006
Author:nikerabbit
Status:old
Tags:
Comment:
* (bug 7459) Magic word variables are always case sensitive
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/MagicWord.php (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -2758,8 +2758,9 @@
27592759 * @private
27602760 */
27612761 function variableSubstitution( $matches ) {
 2762+ global $wgContLang;
27622763 $fname = 'Parser::variableSubstitution';
2763 - $varname = $matches[1];
 2764+ $varname = $wgContLang->lc($matches[1]);
27642765 wfProfileIn( $fname );
27652766 $skip = false;
27662767 if ( $this->mOutputType == OT_WIKI ) {
@@ -2773,8 +2774,14 @@
27742775 }
27752776 if ( !$skip && array_key_exists( $varname, $this->mVariables ) ) {
27762777 $id = $this->mVariables[$varname];
2777 - $text = $this->getVariableValue( $id );
2778 - $this->mOutput->mContainsOldMagic = true;
 2778+ # Now check if we did really match, case sensitive or not
 2779+ $mw =& MagicWord::get( $id );
 2780+ if ($mw->match($matches[1])) {
 2781+ $text = $this->getVariableValue( $id );
 2782+ $this->mOutput->mContainsOldMagic = true;
 2783+ } else {
 2784+ $text = $matches[0];
 2785+ }
27792786 } else {
27802787 $text = $matches[0];
27812788 }
Index: trunk/phase3/includes/MagicWord.php
@@ -178,7 +178,7 @@
179179 $escSyn[] = preg_quote( $synonym, '/' );
180180 $this->mBaseRegex = implode( '|', $escSyn );
181181
182 - $case = $this->mCaseSensitive ? '' : 'i';
 182+ $case = $this->mCaseSensitive ? '' : 'iu';
183183 $this->mRegex = "/{$this->mBaseRegex}/{$case}";
184184 $this->mRegexStart = "/^(?:{$this->mBaseRegex})/{$case}";
185185 $this->mVariableRegex = str_replace( "\\$1", "(.*?)", $this->mRegex );
@@ -205,7 +205,7 @@
206206 if ( $this->mRegex === '' )
207207 $this->initRegex();
208208
209 - return $this->mCaseSensitive ? '' : 'i';
 209+ return $this->mCaseSensitive ? '' : 'iu';
210210 }
211211
212212 /**
@@ -378,8 +378,9 @@
379379 * lookup in a list of magic words
380380 */
381381 function addToArray( &$array, $value ) {
 382+ global $wgContLang;
382383 foreach ( $this->mSynonyms as $syn ) {
383 - $array[$syn] = $value;
 384+ $array[$wgContLang->lc($syn)] = $value;
384385 }
385386 }
386387
Index: trunk/phase3/RELEASE-NOTES
@@ -271,6 +271,7 @@
272272 * (bug 7499) Corrections to Swedish talk namespace names
273273 * (bug 7508) Added option to compress HTML pages by dumpHTML.php
274274 * (bug 7519) Add plural in SpecialWatchlist
 275+* (bug 7459) Magic word variables are always case sensitive
275276
276277 == Languages updated ==
277278