r51002 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51001‎ | r51002 | r51003 >
Date:07:46, 26 May 2009
Author:tstarling
Status:resolved (Comments)
Tags:
Comment:
Reverted r49855, r49656, r49401, r49399, r49397. The language converter cannot be used outside the parser at present without generating a large number of bugs, due to global lifetime state variables, inappropriate $wgParser references, etc. Some refactoring needs to be done before it can be used in this way.
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.class.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.i18n.php (modified) (history)
  • /trunk/extensions/AbuseFilter/AbuseFilter.parser.php (modified) (history)
  • /trunk/extensions/CategoryTree/CategoryTreeFunctions.php (modified) (history)
  • /trunk/phase3/includes/CategoryPage.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageConverter.php
@@ -505,11 +505,10 @@
506506 *
507507 * @param string $text text to be converted
508508 * @param bool $isTitle whether this conversion is for the article title
509 - * @param string $variant the variant we convert to
510509 * @return string converted text
511510 * @public
512511 */
513 - function convert( $text, $isTitle = false, $variant = null ) {
 512+ function convert( $text, $isTitle = false ) {
514513
515514 $mw =& MagicWord::get( 'notitleconvert' );
516515 if( $mw->matchAndRemove( $text ) )
@@ -524,10 +523,7 @@
525524 if( $mw->matchStart( $text ) )
526525 return $text;
527526
528 - if( $variant && in_array( $variant, $this->mVariants ) )
529 - $plang = $variant;
530 - else
531 - $plang = $this->getPreferredVariant();
 527+ $plang = $this->getPreferredVariant();
532528
533529 // for title convertion
534530 if ( $isTitle ) return $this->convertTitle( $text, $plang );
Index: trunk/phase3/languages/Language.php
@@ -35,7 +35,7 @@
3636 class FakeConverter {
3737 var $mLang;
3838 function FakeConverter($langobj) {$this->mLang = $langobj;}
39 - function convert($t, $i, $v) {return $t;}
 39+ function convert($t, $i) {return $t;}
4040 function parserConvert($t, $p) {return $t;}
4141 function getVariants() { return array( $this->mLang->getCode() ); }
4242 function getPreferredVariant() {return $this->mLang->getCode(); }
@@ -2244,8 +2244,8 @@
22452245 }
22462246
22472247 # convert text to different variants of a language.
2248 - function convert( $text, $isTitle = false, $variant = null ) {
2249 - return $this->mConverter->convert($text, $isTitle, $variant);
 2248+ function convert( $text, $isTitle = false) {
 2249+ return $this->mConverter->convert($text, $isTitle);
22502250 }
22512251
22522252 # Convert text from within Parser
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -1968,9 +1968,7 @@
19691969 }
19701970
19711971 wfProfileOut( $fname );
1972 - // Use $wgContLang to get a converted string by language.
1973 - global $wgContLang;
1974 - return $wgContLang->convert( $notice );
 1972+ return $notice;
19751973 }
19761974
19771975 function wfGetNamespaceNotice() {
Index: trunk/phase3/includes/CategoryPage.php
@@ -189,7 +189,7 @@
190190 */
191191 function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) {
192192 global $wgContLang;
193 - $titletext = $wgContLang->convertHtml( $title->getPrefixedText(), true );
 193+ $titletext = $wgContLang->convertHtml( $title->getPrefixedText() );
194194 $this->articles[] = $isRedirect
195195 ? '<span class="redirect-in-category">' . $this->getSkin()->makeKnownLinkObj( $title, $titletext ) . '</span>'
196196 : $this->getSkin()->makeSizeLinkObj( $pageLength, $title, $titletext );
Index: trunk/extensions/CategoryTree/CategoryTreeFunctions.php
@@ -588,7 +588,6 @@
589589 * $info must be an associative array, containing at least a Title object under the 'title' key.
590590 */
591591 function renderNodeInfo( $title, $cat, $children = 0, $loadchildren = false ) {
592 - global $wgContLang;
593592 static $uniq = 0;
594593
595594 $this->init(); # initialize messages
Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php
@@ -365,7 +365,6 @@
366366 'bool' => 'castBool',
367367 'norm' => 'funcNorm',
368368 'ccnorm' => 'funcCCNorm',
369 - 'convert' => 'funcConvert',
370369 'specialratio' => 'funcSpecialRatio',
371370 'rmspecials' => 'funcRMSpecials',
372371 'rmdoubles' => 'funcRMDoubles',
@@ -1257,16 +1256,6 @@
12581257 return new AFPData( AFPData::DString, $wgContLang->lc( $s ) );
12591258 }
12601259
1261 - protected function funcConvert( $args ) {
1262 - global $wgContLang;
1263 - if( count( $args ) < 2 )
1264 - throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos,
1265 - array( 'lang_convert', 2, count($args) ) );
1266 - $v = $args[0]->toString();
1267 - $s = $args[1]->toString();
1268 - return new AFPData( AFPData::DString, $wgContLang->convert( $s, false, $v ) );
1269 - }
1270 -
12711260 protected function funcLen( $args ) {
12721261 if( count( $args ) < 1 )
12731262 throw new AFPUserVisibleException( 'notenoughargs', $this->mCur->pos,
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php
@@ -57,7 +57,6 @@
5858 'length(string)' => 'length',
5959 'lcase(string)' => 'lcase',
6060 'ccnorm(string)' => 'ccnorm',
61 - 'convert("vairant", string)' => 'convert',
6261 'rmdoubles(string)' => 'rmdoubles',
6362 'specialratio(string)' => 'specialratio',
6463 'norm(string)' => 'norm',
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php
@@ -246,7 +246,6 @@
247247 'abusefilter-edit-builder-funcs-length' => 'String length (length)',
248248 'abusefilter-edit-builder-funcs-lcase' => 'To lower case (lcase)',
249249 'abusefilter-edit-builder-funcs-ccnorm' => 'Normalise confusable characters (ccnorm)',
250 - 'abusefilter-edit-builder-funcs-convert' => 'Convert string to specified variant (convert)',
251250 'abusefilter-edit-builder-funcs-rmdoubles' => 'Remove double-characters (rmdoubles)',
252251 'abusefilter-edit-builder-funcs-specialratio' => 'Special characters / total characters (specialratio)',
253252 'abusefilter-edit-builder-funcs-norm' => 'Normalise (norm)',
@@ -17712,7 +17711,6 @@
1771317712 'abusefilter-edit-builder-funcs-length' => '字符串长度(length)',
1771417713 'abusefilter-edit-builder-funcs-lcase' => '字母小写化(lcase)',
1771517714 'abusefilter-edit-builder-funcs-ccnorm' => '规范化易混淆字符(ccnorm)',
17716 - 'abusefilter-edit-builder-funcs-convert' => '转换字符串到指定语言(convert)',
1771717715 'abusefilter-edit-builder-funcs-rmdoubles' => '去除双字节字符(rmdoubles)',
1771817716 'abusefilter-edit-builder-funcs-specialratio' => '特殊字符比(specialratio)',
1771917717 'abusefilter-edit-builder-funcs-norm' => '规范化(norm)',
@@ -18073,14 +18071,13 @@
1807418072 'abusefilter-edit-builder-misc-cond' => '條件式(if X then Y else Z)',
1807518073 'abusefilter-edit-builder-group-funcs' => '函數',
1807618074 'abusefilter-edit-builder-funcs-length' => '字串長度(length)',
18077 - 'abusefilter-edit-builder-funcs-lcase' => '改為小寫(lcase)',
18078 - 'abusefilter-edit-builder-funcs-ccnorm' => '修正混淆字符(ccnorm)',
18079 - 'abusefilter-edit-builder-funcs-convert' => '轉換字串到指定語言(convert)',
18080 - 'abusefilter-edit-builder-funcs-rmdoubles' => '去除雙字元(rmdoubles)',
18081 - 'abusefilter-edit-builder-funcs-specialratio' => '特殊字元數與整體字元數比(specialratio)',
 18075+ 'abusefilter-edit-builder-funcs-lcase' => '改為小寫(lcase)',
 18076+ 'abusefilter-edit-builder-funcs-ccnorm' => '修正混淆字符(ccnorm)',
 18077+ 'abusefilter-edit-builder-funcs-rmdoubles' => '去除雙字元(rmdoubles)',
 18078+ 'abusefilter-edit-builder-funcs-specialratio' => '特殊字元數與整體字元數比(specialratio)',
1808218079 'abusefilter-edit-builder-funcs-norm' => '正常化(norm)',
18083 - 'abusefilter-edit-builder-funcs-count' => '字串 X 在字串 Y 裡出現的次數(count)',
18084 - 'abusefilter-edit-builder-funcs-rcount' => '正則表示式 X 出現在字串 Y 的次數(rcount)',
 18080+ 'abusefilter-edit-builder-funcs-count' => '字串 X 在字串 Y 裡出現的次數(count)',
 18081+ 'abusefilter-edit-builder-funcs-rcount' => '正則表示式 X 出現在字串 Y 的次數(rcount)',
1808518082 'abusefilter-edit-builder-funcs-rmwhitespace' => '去除空白字元(rmwhitespace)',
1808618083 'abusefilter-edit-builder-funcs-rmspecials' => '去除特殊字元(rmspecials)',
1808718084 'abusefilter-edit-builder-funcs-ip_in_range' => 'IP是否在範圍內?(ip_in_range)',

Follow-up revisions

RevisionCommit summaryAuthorDate
r51048Fixed r51002 by also reverting r49856.tstarling06:17, 27 May 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49397A new optional param for LanguageConverter::convert(), to enable a new functi...philip10:56, 11 April 2009
r49399Add a new function named 'convert()', allow user to convert a string to speci...philip10:59, 11 April 2009
r49401PHP doesn't have a "none" constant, changed to "null"ialex11:24, 11 April 2009
r49656Enabled LanguageConverter on CachedNotice to get a correct output.philip04:29, 20 April 2009
r49855Enabled LanguageConverter on extension:CategoryTree....philip05:13, 25 April 2009

Comments

#Comment by Nikerabbit (talk | contribs)   17:15, 26 May 2009

This broke CategoryTree:

[26-May-2009 17:01:32] PHP Notice: Undefined variable: wgContLang in /var/www/w/extensions/CategoryTree/CategoryTreeFunctions.php on line 619

[26-May-2009 17:01:32] PHP Fatal error: Call to a member function convertHtml() on a non-object in /var/www/w/extensions/CategoryTree/CategoryTreeFunctions.php on line 619

#Comment by Tim Starling (talk | contribs)   06:18, 27 May 2009

Should be fixed now.

Status & tagging log