* (bug 7459) Magic word variables are always case sensitive
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Sun, 8 Oct 2006 13:00:42 +0000 (13:00 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Sun, 8 Oct 2006 13:00:42 +0000 (13:00 +0000)
RELEASE-NOTES
includes/MagicWord.php
includes/Parser.php

index bb60b2a..4381ae4 100644 (file)
@@ -271,6 +271,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 7499) Corrections to Swedish talk namespace names
 * (bug 7508) Added option to compress HTML pages by dumpHTML.php
 * (bug 7519) Add plural in SpecialWatchlist
+* (bug 7459) Magic word variables are always case sensitive
 
 == Languages updated ==
 
index 511efab..68cbe34 100644 (file)
@@ -178,7 +178,7 @@ class MagicWord {
                        $escSyn[] = preg_quote( $synonym, '/' );
                $this->mBaseRegex = implode( '|', $escSyn );
                
-               $case = $this->mCaseSensitive ? '' : 'i';
+               $case = $this->mCaseSensitive ? '' : 'iu';
                $this->mRegex = "/{$this->mBaseRegex}/{$case}";
                $this->mRegexStart = "/^(?:{$this->mBaseRegex})/{$case}";
                $this->mVariableRegex = str_replace( "\\$1", "(.*?)", $this->mRegex );
@@ -205,7 +205,7 @@ class MagicWord {
                if ( $this->mRegex === '' )
                        $this->initRegex();
 
-               return $this->mCaseSensitive ? '' : 'i';
+               return $this->mCaseSensitive ? '' : 'iu';
        }
 
        /**
@@ -378,8 +378,9 @@ class MagicWord {
         * lookup in a list of magic words
         */
        function addToArray( &$array, $value ) {
+               global $wgContLang;
                foreach ( $this->mSynonyms as $syn ) {
-                       $array[$syn] = $value;
+                       $array[$wgContLang->lc($syn)] = $value;
                }
        }
 
index 6481009..bf386ae 100644 (file)
@@ -2758,8 +2758,9 @@ class Parser
         * @private
         */
        function variableSubstitution( $matches ) {
+               global $wgContLang;
                $fname = 'Parser::variableSubstitution';
-               $varname = $matches[1];
+               $varname = $wgContLang->lc($matches[1]);
                wfProfileIn( $fname );
                $skip = false;
                if ( $this->mOutputType == OT_WIKI ) {
@@ -2773,8 +2774,14 @@ class Parser
                }
                if ( !$skip && array_key_exists( $varname, $this->mVariables ) ) {
                        $id = $this->mVariables[$varname];
-                       $text = $this->getVariableValue( $id );
-                       $this->mOutput->mContainsOldMagic = true;
+                       # Now check if we did really match, case sensitive or not
+                       $mw =& MagicWord::get( $id );
+                       if ($mw->match($matches[1])) {
+                               $text = $this->getVariableValue( $id );
+                               $this->mOutput->mContainsOldMagic = true;
+                       } else {
+                               $text = $matches[0];
+                       }
                } else {
                        $text = $matches[0];
                }