r51405 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51404‎ | r51405 | r51406 >
Date:14:51, 3 June 2009
Author:tstarling
Status:deferred
Tags:
Comment:
Reverted r48984. Fragile, doesn't work if memcached is enabled. See CodeReview.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -76,7 +76,6 @@
7777 $parser->setFunctionHook( 'revisionuser', array( __CLASS__, 'revisionuser' ), SFH_NO_HASH );
7878 $parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), SFH_OBJECT_ARGS );
7979 $parser->setFunctionHook( 'formatdate', array( __CLASS__, 'formatDate' ) );
80 - $parser->setFunctionHook( 'groupconvert', array( __CLASS__, 'groupconvert' ), SFH_NO_HASH );
8180
8281 if ( $wgAllowDisplayTitle ) {
8382 $parser->setFunctionHook( 'displaytitle', array( __CLASS__, 'displaytitle' ), SFH_NO_HASH );
@@ -113,7 +112,7 @@
114113 $date = $df->reformat( $pref, $date, array('match-whole') );
115114 return $date;
116115 }
117 -
 116+
118117 static function ns( $parser, $part1 = '' ) {
119118 global $wgContLang;
120119 if ( intval( $part1 ) || $part1 == "0" ) {
@@ -738,12 +737,4 @@
739738 );
740739 return $parser->extensionSubstitution( $params, $frame );
741740 }
742 -
743 - /**
744 - * magic word call for a group convert from LanguageConverter.
745 - */
746 - public static function groupconvert( $parser, $group ) {
747 - global $wgContLang;
748 - return $wgContLang->groupConvert( $group );
749 - }
750741 }
Index: trunk/phase3/languages/LanguageConverter.php
@@ -34,7 +34,6 @@
3535 var $mFlags;
3636 var $mDescCodeSep = ':',$mDescVarSep = ';';
3737 var $mUcfirst = false;
38 - var $mGroups = array();
3938
4039 const CACHE_VERSION_KEY = 'VERSION 6';
4140
@@ -436,7 +435,7 @@
437436
438437 /* don't do anything if this is the conversion table */
439438 if ( $parser->getTitle()->getNamespace() == NS_MEDIAWIKI &&
440 - strpos($parser->mTitle->getText(), 'onversiontable') !== false )
 439+ strpos($parser->mTitle->getText(), "Conversiontable") !== false )
441440 {
442441 return $text;
443442 }
@@ -685,7 +684,7 @@
686685 * load conversion tables either from the cache or the disk
687686 * @private
688687 */
689 - function loadTables( $fromcache = true ) {
 688+ function loadTables($fromcache=true) {
690689 global $wgMemc;
691690 if( $this->mTablesLoaded )
692691 return;
@@ -703,14 +702,9 @@
704703 // we will first load the default tables
705704 // then update them using things in MediaWiki:Zhconversiontable/*
706705 $this->loadDefaultTables();
707 - foreach( $this->mVariants as $var ) {
708 - $cached = $this->parseCachedTable( $var );
709 - // load group convert table, e.g. [[MediaWiki:Groupconversiontable-StarTrek]].
710 - foreach( $this->mGroups as $group ) {
711 - $cachedgroup = $this->parseCachedTable( $var, '', true, "Groupconversiontable-$group" );
712 - $cached = array_merge( $cached, $cachedgroup );
713 - }
714 - $this->mTables[$var]->mergeArray( $cached );
 706+ foreach($this->mVariants as $var) {
 707+ $cached = $this->parseCachedTable($var);
 708+ $this->mTables[$var]->mergeArray($cached);
715709 }
716710
717711 $this->postLoadTables();
@@ -758,24 +752,24 @@
759753 * and will be parsed recursively if $recursive=true
760754 *
761755 */
762 - function parseCachedTable($code, $subpage='', $recursive=true, $table='Conversiontable') {
 756+ function parseCachedTable($code, $subpage='', $recursive=true) {
763757 global $wgMessageCache;
764758 static $parsed = array();
765759
766760 if(!is_object($wgMessageCache))
767761 return array();
768762
769 - $key = "$table/".$code;
 763+ $key = 'Conversiontable/'.$code;
770764 if($subpage)
771765 $key .= '/' . $subpage;
772766
773767 if(array_key_exists($key, $parsed))
774768 return array();
775 -
 769+
776770 if ( strpos( $code, '/' ) === false ) {
777 - $txt = $wgMessageCache->get( $table, true, $code );
 771+ $txt = $wgMessageCache->get( 'Conversiontable', true, $code );
778772 } else {
779 - $title = Title::makeTitleSafe( NS_MEDIAWIKI, "$table/$code" );
 773+ $title = Title::makeTitleSafe( NS_MEDIAWIKI, "Conversiontable/$code" );
780774 if ( $title && $title->exists() ) {
781775 $article = new Article( $title );
782776 $txt = $article->getContents();
@@ -783,9 +777,10 @@
784778 $txt = '';
785779 }
786780 }
 781+
787782 // get all subpage links of the form
788783 // [[MediaWiki:conversiontable/zh-xx/...|...]]
789 - $linkhead = $this->mLangObj->getNsText(NS_MEDIAWIKI) . ":$table";
 784+ $linkhead = $this->mLangObj->getNsText(NS_MEDIAWIKI) . ':Conversiontable';
790785 $subs = explode('[[', $txt);
791786 $sublinks = array();
792787 foreach( $subs as $sub ) {
@@ -804,6 +799,7 @@
805800 }
806801 }
807802
 803+
808804 // parse the mappings in this page
809805 $blocks = explode($this->mMarkup['begin'], $txt);
810806 array_shift($blocks);
@@ -897,17 +893,6 @@
898894 $ret = $this->mMarkup['begin'] . 'R|' . $text . $this->mMarkup['end'];
899895 return $ret;
900896 }
901 -
902 - /**
903 - * Callback function for magicword 'groupconvert'
904 - *
905 - * @param string $group: the group name called for
906 - * @return blank string
907 - */
908 - function groupConvert( $group ) {
909 - $this->mGroups[] = $group;
910 - return '';
911 - }
912897 }
913898
914899 /**
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -344,7 +344,6 @@
345345 'staticredirect' => array( 1, '__STATICREDIRECT__' ),
346346 'protectionlevel' => array( 1, 'PROTECTIONLEVEL' ),
347347 'formatdate' => array( 0, 'formatdate', 'dateformat' ),
348 - 'groupconvert' => array( 0, 'GROUPCONVERT:', 'GC:' ),
349348 );
350349
351350 /**
Index: trunk/phase3/languages/Language.php
@@ -47,7 +47,6 @@
4848 function convertCategoryKey( $key ) {return $key; }
4949 function convertLinkToAllVariants($text){ return array( $this->mLang->getCode() => $text); }
5050 function armourMath($text){ return $text; }
51 - function groupConvert($group) {return '';}
5251 }
5352
5453 /**
@@ -2358,16 +2357,6 @@
23592358 function markNoConversion( $text, $noParse=false ) {
23602359 return $this->mConverter->markNoConversion( $text, $noParse );
23612360 }
2362 -
2363 - /**
2364 - * Callback function for magicword 'groupconvert'
2365 - *
2366 - * @param string $group: the group name called for
2367 - * @return blank string
2368 - */
2369 - function groupConvert( $group ) {
2370 - return $this->mConverter->groupConvert( $group );
2371 - }
23722361
23732362 /**
23742363 * A regular expression to match legal word-trailing characters
Index: trunk/phase3/RELEASE-NOTES
@@ -46,9 +46,6 @@
4747 * Add CSS defintion of the 'wikitable' class to shared.css
4848 * (bug 17163) Added MediaWiki:Talkpageheader which will be displayed when
4949 viewing talk pages
50 -* Add group convertsion support for LanguageConverter. New magic word
51 - "{{GROUPCONVERT:xxx}}" enabled for this new feature. You can set related
52 - conversion rules in [[MediaWiki:Groupconversiontable-xxx/language_code]].
5350 * Superfluous border="0" removed from images
5451 * Added new hook 'MessageCacheReplace' into MessageCache.php. For instance
5552 to allow extensions to update caches in similar way as MediaWiki invalidates

Follow-up revisions

RevisionCommit summaryAuthorDate
r51406Follow-up to r51405 (Reverted r48984)....siebrand15:02, 3 June 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r48984Add group convertsion support for LanguageConverter. New magic word "{{GROUPC...philip08:55, 29 March 2009

Status & tagging log