Revert r45642 "* Fixing the caching issue by using -{T|xxx}- syntax (only applies...
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 14 Jan 2009 19:14:20 +0000 (19:14 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 14 Jan 2009 19:14:20 +0000 (19:14 +0000)
Causes parser test regression and other problems noted in code review.

RELEASE-NOTES
includes/parser/Parser.php
languages/LanguageConverter.php
languages/messages/MessagesZh_hans.php
maintenance/updateRestrictions.php

index e709d3d..9ca6a6b 100644 (file)
@@ -39,10 +39,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 16852) padleft and padright now accept multiletter pad characters
   
 === Bug fixes in 1.15 ===
-* Fixing the caching issue by using -{T|xxx}- syntax (only applies on wiki with
-  LanguageConverter class)
-* Improving the efficiency by using -{A|xxx}- syntax (only applies on wiki with
-  LanguageConverter class)
 * (bug 16968) Special:Upload no longer throws useless warnings.
 * (bug 15470) Special:Upload no longer force-capitalizes titles
 * (bug 17000) Special:RevisionDelete now checks if the database is locked before
index 504660a..40b5b97 100644 (file)
@@ -3310,7 +3310,6 @@ class Parser
                                                throw new MWException( '<html> extension tag encountered unexpectedly' );
                                        }
                                case 'nowiki':
-                                       $content = strtr($content, array('-{' => '-&#123;', '}-' => '&#125;-'));
                                        $output = Xml::escapeTagsOnly( $content );
                                        break;
                                case 'math':
index 56e5e42..dd69e82 100644 (file)
@@ -13,7 +13,7 @@
  * @ingroup Language
  *
  * @author Zhengzhu Feng <zhengzhu@gmail.com>
- * @maintainers fdcn <fdcn64@gmail.com>, shinjiman <shinjiman@gmail.com>, PhiLiP <philip.npc@gmail.com>
+ * @maintainers fdcn <fdcn64@gmail.com>, shinjiman <shinjiman@gmail.com>
  */
 class LanguageConverter {
        var $mPreferredVariant='';
@@ -21,8 +21,6 @@ class LanguageConverter {
        var $mVariants, $mVariantFallbacks, $mVariantNames;
        var $mTablesLoaded = false;
        var $mTables;
-       var $mManualAddTables;
-       var $mManualRemoveTables;
        var $mTitleDisplay='';
        var $mDoTitleConvert=true, $mDoContentConvert=true;
        var $mManualLevel; // 'bidirectional' 'unidirectional' 'disable' for each variants
@@ -83,13 +81,10 @@ class LanguageConverter {
                        'N'=>'N'        // current variant name
                );
                $this->mFlags = array_merge($f, $flags);
-               foreach( $this->mVariants as $v) {
+               foreach( $this->mVariants as $v)
                        $this->mManualLevel[$v]=array_key_exists($v,$manualLevel)
                                                                ?$manualLevel[$v]
                                                                :'bidirectional';
-                       $this->mManualAddTables[$v] = array();
-                       $this->mManualRemoveTables[$v] = array();
-               }
        }
 
        /**
@@ -328,12 +323,13 @@ class LanguageConverter {
 
                return $ret;
        }
-       
+
+
        /**
-        * prepare manual conversion table
+        * apply manual conversion
         * @private
         */
-       function prepareManualConv($convRule){
+       function applyManualConv($convRule){
                // use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom conversion in title
                $title = $convRule->getTitle();
                if($title){
@@ -346,29 +342,10 @@ class LanguageConverter {
                $action = $convRule->getRulesAction();
                foreach($convTable as $v=>$t) {
                        if( !in_array($v,$this->mVariants) )continue;
-                       if( $action=="add" ) {
-                               foreach($t as $from=>$to) {
-                                       // more efficient than array_merge(), about 2.5 times.
-                                       $this->mManualAddTables[$v][$from] = $to;
-                               }
-                       }
+                       if( $action=="add" )
+                               $this->mTables[$v]->mergeArray($t);
                        elseif ( $action=="remove" )
-                               $this->mManualRemoveTables[$v] = array_merge($this->mManualRemoveTables[$v], $t);
-               }
-       }
-
-       /**
-        * apply manual conversion from $this->mManualAddTables and $this->mManualRemoveTables
-        * @private
-        */
-       function applyManualConv(){
-               //apply manual conversion table to global table
-               foreach($this->mVariants as $v) {
-                       if (count($this->mManualAddTables[$v]) > 0) {
-                               $this->mTables[$v]->mergeArray($this->mManualAddTables[$v]);
-                       }
-                       if (count($this->mManualRemoveTables[$v]) > 0)
-                               $this->mTables[$v]->removeArray($this->mManualRemoveTables[$v]);
+                               $this->mTables[$v]->removeArray($t);
                }
        }
 
@@ -461,26 +438,32 @@ class LanguageConverter {
                $plang = $this->getPreferredVariant();
                $tarray = StringUtils::explode($this->mMarkup['end'], $text);
                $text = '';
-
-               $marks = array();
+               $lastDelim = false;
                foreach($tarray as $txt) {
                        $marked = explode($this->mMarkup['begin'], $txt, 2);
-                       if (array_key_exists(1, $marked)) {
-                               $crule = new ConverterRule($marked[1], $this);
-                               $crule->parse($plang);
-                               $marked[1] = $crule->getDisplay();
-                               $this->prepareManualConv($crule);
-                       }
-                       array_push($marks, $marked);
-               }
-               $this->applyManualConv();
-               foreach ($marks as $marked) {
+
                        if( $this->mDoContentConvert )
                                $text .= $this->autoConvert($marked[0],$plang);
                        else
                                $text .= $marked[0];
-                       if( array_key_exists(1, $marked) )
-                               $text .= $marked[1];
+
+                       if(array_key_exists(1, $marked)){
+                               // strip the flags from syntax like -{T| ... }-
+                               $crule = new ConverterRule($marked[1], $this);
+                               $crule->parse($plang);
+
+                               $text .= $crule->getDisplay();
+                               $this->applyManualConv($crule);
+                               $lastDelim = false;
+                       } else {
+                               // Reinsert the }- which wasn't part of anything
+                               $text .= $this->mMarkup['end'];
+                               $lastDelim = true;
+                       }
+               }
+               if ( $lastDelim ) {
+                       // Remove the last delimiter (wasn't real)
+                       $text = substr( $text, 0, -strlen( $this->mMarkup['end'] ) );
                }
 
                return $text;
@@ -817,7 +800,6 @@ class LanguageConverter {
  * @ingroup Language
  * @author  fdcn <fdcn64@gmail.com>
  */
-
 class ConverterRule {
        var $mText; // original text in -{text}-
        var $mConverter; // LanguageConverter object 
index 075c81b..40eed49 100644 (file)
@@ -67,7 +67,6 @@ $specialPageAliases = array(
        'Preferences'               => array( '参数设置' ),
        'Watchlist'                 => array( '监视列表' ),
        'Recentchanges'             => array( '最近更改' ),
-       'Recentchangeslinked'       => array( '链出更改' ),
        'Upload'                    => array( '上传文件' ),
        'Listfiles'                 => array( '文件列表' ),
        'Newimages'                 => array( '新建文件' ),
@@ -80,7 +79,7 @@ $specialPageAliases = array(
        'Uncategorizedcategories'   => array( '未归类分类' ),
        'Uncategorizedimages'       => array( '未归类文件' ),
        'Uncategorizedtemplates'    => array( '未归类模版' ),
-       'Unusedcategories'          => array( '未使用分类' ),
+       'Unusedcategories'          => array( '未使用的模板' ),
        'Unusedimages'              => array( '未使用文件' ),
        'Wantedpages'               => array( '待撰页面' ),
        'Wantedcategories'          => array( '待撰分类' ),
index dd6b5f7..1c5bfae 100644 (file)
@@ -82,7 +82,7 @@ function migrate_page_restrictions( $db ) {
        // Kill any broken rows from previous imports
        $db->delete( 'page_restrictions', array( 'pr_level' => '' ) );
        // Kill other invalid rows
-       $db->deleteJoin( 'page_restrictions', 'page', 'pr_page', 'page_id', array('page_namespace' => NS_MEDIAWIKI) );
+       #$db->deleteJoin( 'page_restrictions', 'page', 'pr_page', 'page_id', array('page_namespace' => NS_MEDIAWIKI) );
        echo "...Done!\n";
 }