r51128 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51127‎ | r51128 | r51129 >
Date:18:13, 28 May 2009
Author:shinjiman
Status:reverted (Comments)
Tags:
Comment:
* (bug 18958) Added ability to disable entire variant conversion engine per user preferences (languages with language converter class only)
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Preferences.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesGan_hans.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesGan_hant.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesJa.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesKk.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesKk_arab.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesKk_cyrl.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesKk_latn.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesLzh.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesQqq.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesSr.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesSr_ec.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesSr_el.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesYue.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh_hans.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh_hant.php (modified) (history)
  • /trunk/phase3/maintenance/language/messageTypes.inc (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)
  • /trunk/phase3/skins/Vector.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/messages/MessagesGan_hans.php
@@ -64,7 +64,7 @@
6565 'tog-watchlisthideown' => '监视列表弆到偶𠮶编辑',
6666 'tog-watchlisthidebots' => '监视列表弆到机器人𠮶编辑',
6767 'tog-watchlisthideminor' => '监视列表弆到细修改',
68 -'tog-nolangconversion' => '嫑字转换',
 68+'tog-variantconversion' => '要字转换',
6969 'tog-ccmeonemails' => '偶发email到人家时也发封副本到偶',
7070 'tog-diffonly' => '比较两只版本差异𠮶时间伓显示文章𠮶内容',
7171 'tog-showhiddencats' => '显示弆到𠮶分类',
Index: trunk/phase3/languages/messages/MessagesZh_hans.php
@@ -73,7 +73,7 @@
7474 '分类讨论'=> NS_CATEGORY_TALK,
7575 );
7676
77 -$specialPageAliases = array(
 77+/*$specialPageAliases = array(
7878 'DoubleRedirects' => array( '双重重定向页面' ),
7979 'BrokenRedirects' => array( '损坏的重定向页' ),
8080 'Disambiguations' => array( '消歧义页' ),
@@ -162,11 +162,8 @@
163163 'DeletedContributions' => array( '已删除的用户贡献' ),
164164 'Tags' => array( '标签' ),
165165 'Createpage' => array( '创建页面' ),
166 -);
 166+);*/
167167
168 -$extraUserToggles = array(
169 - 'nolangconversion',
170 -);
171168 $datePreferences = array(
172169 'default',
173170 'ISO 8601',
@@ -232,7 +229,7 @@
233230 'tog-watchlisthideliu' => '在监视列表中隐藏登录用户',
234231 'tog-watchlisthideanons' => '在监视列表中隐藏匿名用户',
235232 'tog-watchlisthidepatrolled' => '在监视列表中隐藏已巡查的编辑',
236 -'tog-nolangconversion' => '不进行字词转换',
 233+'tog-variantconversion' => '进行字词转换',
237234 'tog-ccmeonemails' => '把我发送给其他用户的邮件同时发送副本给我自己',
238235 'tog-diffonly' => '在比较两个修订版本差异时不显示页面内容',
239236 'tog-showhiddencats' => '显示隐藏分类',
Index: trunk/phase3/languages/messages/MessagesSr_ec.php
@@ -60,11 +60,6 @@
6161 'Razgovor_o_kategoriji' => NS_CATEGORY_TALK,
6262 );
6363
64 -
65 -$extraUserToggles = array(
66 - 'nolangconversion',
67 -);
68 -
6964 $datePreferenceMigrationMap = array(
7065 'default',
7166 'hh:mm d. month y.',
Index: trunk/phase3/languages/messages/MessagesYue.php
@@ -182,7 +182,7 @@
183183 'tog-watchlisthideliu' => '響監視清單度隱藏登入用戶',
184184 'tog-watchlisthideanons' => '響監視清單度隱藏匿名用戶',
185185 'tog-watchlisthidepatrolled' => '響監視清單度隱藏巡查過嘅編輯',
186 -'tog-nolangconversion' => '唔要用字轉換',
 186+'tog-variantconversion' => '要用字轉換',
187187 'tog-ccmeonemails' => '當我寄電郵畀其他人嗰陣寄返封副本畀我',
188188 'tog-diffonly' => '響差異下面唔顯示頁面內容',
189189 'tog-showhiddencats' => '顯示隱藏類',
Index: trunk/phase3/languages/messages/MessagesGan_hant.php
@@ -89,7 +89,7 @@
9090 'tog-watchlisthideown' => '監視列表弆到偶嗰編輯',
9191 'tog-watchlisthidebots' => '監視列表弆到機器人嗰編輯',
9292 'tog-watchlisthideminor' => '監視列表弆到細修改',
93 -'tog-nolangconversion' => '嫑字轉換',
 93+'tog-variantconversion' => '要字轉換',
9494 'tog-ccmeonemails' => '偶發email到人家時也發封副本到偶',
9595 'tog-diffonly' => '比較兩隻版本差異嗰時間伓顯示文章嗰內容',
9696 'tog-showhiddencats' => '顯示弆到嗰分類',
Index: trunk/phase3/languages/messages/MessagesKk_arab.php
@@ -51,10 +51,6 @@
5252 'underline' => 0,
5353 );
5454
55 -$extraUserToggles = array(
56 - 'nolangconversion'
57 -);
58 -
5955 $fallback8bitEncoding = 'windows-1256';
6056
6157 $namespaceNames = array(
Index: trunk/phase3/languages/messages/MessagesZh_hant.php
@@ -78,7 +78,7 @@
7979 "分類討論" => NS_CATEGORY_TALK,
8080 );
8181
82 -$specialPageAliases = array(
 82+/*$specialPageAliases = array(
8383 'DoubleRedirects' => array( '雙重重定向頁面' ),
8484 'BrokenRedirects' => array( '損壞的重定向頁' ),
8585 'Userlogin' => array( '用戶登入' ),
@@ -155,7 +155,7 @@
156156 'DeletedContributions' => array( '已刪除的用戶貢獻' ),
157157 'Tags' => array( '標籤' ),
158158 'Createpage' => array( '創建頁面' ),
159 -);
 159+);*/
160160
161161 $bookstoreList = array(
162162 '博客來書店' => 'http://www.books.com.tw/exep/prod/booksfile.php?item=$1',
@@ -207,7 +207,7 @@
208208 'tog-watchlisthideliu' => '監視列表中隱藏登入用戶',
209209 'tog-watchlisthideanons' => '監視列表中隱藏匿名用戶',
210210 'tog-watchlisthidepatrolled' => '監視清單中隱藏已巡查的編輯',
211 -'tog-nolangconversion' => '不進行用字轉換',
 211+'tog-variantconversion' => '進行用字轉換',
212212 'tog-ccmeonemails' => '當我寄電子郵件給其他用戶時,也寄一份複本到我的信箱。',
213213 'tog-diffonly' => '在比較兩個修訂版本差異時不顯示頁面內容',
214214 'tog-showhiddencats' => '顯示隱藏分類',
Index: trunk/phase3/languages/messages/MessagesSr_el.php
@@ -54,11 +54,6 @@
5555 'Разговор_о_категорији' => NS_CATEGORY_TALK,
5656 );
5757
58 -
59 -$extraUserToggles = array(
60 - 'nolangconversion',
61 -);
62 -
6358 $datePreferenceMigrationMap = array(
6459 'default',
6560 'hh:mm d. month y.',
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -538,7 +538,7 @@
539539 'tog-watchlisthideliu' => 'Hide edits by logged in users from the watchlist',
540540 'tog-watchlisthideanons' => 'Hide edits by anonymous users from the watchlist',
541541 'tog-watchlisthidepatrolled' => 'Hide patrolled edits from the watchlist',
542 -'tog-nolangconversion' => 'Disable variants conversion', # only translate this message to other languages if you have to change it
 542+'tog-variantconversion' => 'Enable variants conversion', # only translate this message to other languages if you have to change it
543543 'tog-ccmeonemails' => 'Send me copies of e-mails I send to other users',
544544 'tog-diffonly' => 'Do not show page content below diffs',
545545 'tog-showhiddencats' => 'Show hidden categories',
Index: trunk/phase3/languages/messages/MessagesLzh.php
@@ -106,7 +106,7 @@
107107 'tog-watchlisthideliu' => '不哨有簿',
108108 'tog-watchlisthideanons' => '不哨無簿',
109109 'tog-watchlisthidepatrolled' => '不哨已巡',
110 -'tog-nolangconversion' => '非轉',
 110+'tog-variantconversion' => '轉',
111111 'tog-ccmeonemails' => '凡所遺書,請存副本。',
112112 'tog-diffonly' => '異下無示頁',
113113 'tog-showhiddencats' => '示隱類',
Index: trunk/phase3/languages/messages/MessagesZh.php
@@ -172,6 +172,10 @@
173173 'DeletedContributions' => array( '已删除的用户贡献', '已刪除的用戶貢獻' ),
174174 );
175175
 176+$extraUserToggles = array(
 177+ 'variantconversion',
 178+);
 179+
176180 $messages = array(
177181 # User preference toggles
178182 'tog-norollbackdiff' => '進行回退後略過差異比較',
Index: trunk/phase3/languages/messages/MessagesKk_cyrl.php
@@ -27,10 +27,6 @@
2828 '.' => ',',
2929 );
3030
31 -$extraUserToggles = array(
32 - 'nolangconversion'
33 -);
34 -
3531 $fallback8bitEncoding = 'windows-1251';
3632
3733 $namespaceNames = array(
Index: trunk/phase3/languages/messages/MessagesKk.php
@@ -13,6 +13,10 @@
1414
1515 $fallback = 'kk-cyrl';
1616
 17+$extraUserToggles = array(
 18+ 'variantconversion'
 19+);
 20+
1721 $messages = array(
1822 # Edit pages
1923 'edittools' => '<!-- Мындағы мәтін өңдеу және қотару пішіндердің астында көрсетіледі. -->',
Index: trunk/phase3/languages/messages/MessagesKk_latn.php
@@ -31,10 +31,6 @@
3232 '.' => ',',
3333 );
3434
35 -$extraUserToggles = array(
36 - 'nolangconversion'
37 -);
38 -
3935 $fallback8bitEncoding = 'windows-1254';
4036
4137 $namespaceNames = array(
Index: trunk/phase3/languages/messages/MessagesJa.php
@@ -318,7 +318,7 @@
319319 'tog-watchlisthideliu' => 'ウォッチリストにログイン利用者の編集を表示しない',
320320 'tog-watchlisthideanons' => 'ウォッチリストに匿名利用者の編集を表示しない',
321321 'tog-watchlisthidepatrolled' => 'ウォッチリストにパトロール済みの編集を表示しない',
322 -'tog-nolangconversion' => '言語変種変換を無効にする',
 322+'tog-variantconversion' => '言語変種変換を有効にする',
323323 'tog-ccmeonemails' => '他の利用者に送信したメールの控えを自分にも送る',
324324 'tog-diffonly' => '差分表示の下に記事本文を表示しない',
325325 'tog-showhiddencats' => '隠しカテゴリを表示する',
Index: trunk/phase3/languages/messages/MessagesQqq.php
@@ -127,7 +127,7 @@
128128 'tog-watchlisthideliu' => "Option in tab 'Watchlist' of [[Special:Preferences]]",
129129 'tog-watchlisthideanons' => "Option in tab 'Watchlist' of [[Special:Preferences]]",
130130 'tog-watchlisthidepatrolled' => 'Option in Watchlist tab of [[Special:Preferences]]',
131 -'tog-nolangconversion' => 'In user preferences.',
 131+'tog-variantconversion' => 'In user preferences.',
132132 'tog-ccmeonemails' => 'In user preferences',
133133 'tog-diffonly' => 'Toggle option used in [[Special:Preferences]].',
134134 'tog-showhiddencats' => 'Toggle option used in [[Special:Preferences]].',
Index: trunk/phase3/languages/messages/MessagesSr.php
@@ -14,6 +14,10 @@
1515 $fallback = 'sr-ec';
1616 $linkTrail = '/^([abvgdđežzijklljmnnjoprstćufhcčdžšабвгдђежзијклљмнњопрстћуфхцчџш]+)(.*)$/usD';
1717
 18+$extraUserToggles = array(
 19+ 'variantconversion',
 20+);
 21+
1822 $messages = array(
1923 # Special:LinkSearch
2024 'linksearch' => 'Претрага интернет веза',
Index: trunk/phase3/languages/LanguageConverter.php
@@ -426,7 +426,14 @@
427427 * @public
428428 */
429429 function parserConvert( $text, &$parser ) {
430 - global $wgDisableLangConversion;
 430+ global $wgUser, $wgEnableVariants;
 431+
 432+ /* disable entire conversion engine if the user had been disabled it */
 433+ $variantConv = $wgUser->getOption( 'variantconversion' );
 434+ if ( ( $wgEnableVariants == true ) && ( $variantConv == 0 ) ) {
 435+ $wgEnableVariants = false;
 436+ }
 437+
431438 /* don't do anything if this is the conversion table */
432439 if ( $parser->getTitle()->getNamespace() == NS_MEDIAWIKI &&
433440 strpos($parser->mTitle->getText(), 'onversiontable') !== false )
@@ -434,7 +441,7 @@
435442 return $text;
436443 }
437444
438 - if ( $wgDisableLangConversion )
 445+ if ( !$wgEnableVariants )
439446 return $text;
440447
441448 $text = $this->convert( $text );
@@ -573,11 +580,11 @@
574581 * @public
575582 */
576583 function findVariantLink( &$link, &$nt, $ignoreOtherCond = false ) {
577 - global $wgDisableLangConversion, $wgDisableTitleConversion, $wgRequest, $wgUser;
 584+ global $wgEnableVariants, $wgDisableTitleConversion, $wgRequest, $wgUser;
578585 $isredir = $wgRequest->getText( 'redirect', 'yes' );
579586 $action = $wgRequest->getText( 'action' );
580587 $linkconvert = $wgRequest->getText( 'linkconvert', 'yes' );
581 - $disableLinkConversion = $wgDisableLangConversion || $wgDisableTitleConversion;
 588+ $disableLinkConversion = !$wgEnableVariants || $wgDisableTitleConversion;
582589 $linkBatch = new LinkBatch();
583590
584591 $ns=NS_MAIN;
Index: trunk/phase3/RELEASE-NOTES
@@ -74,6 +74,8 @@
7575 * (bug 18860) Blocks of IPs affecting registered users can now block email
7676 * (bug 17093) Date and time are separate parameters in Special:BlockList
7777 * (bug 11484) Added ISO speed rating to default collapsed EXIF metadata view
 78+* (bug 18958) Added ability to disable entire variant conversion engine
 79+ per user preferences
7880
7981 === Bug fixes in 1.16 ===
8082
Index: trunk/phase3/maintenance/language/messages.inc
@@ -53,7 +53,7 @@
5454 'tog-watchlisthideliu',
5555 'tog-watchlisthideanons',
5656 'tog-watchlisthidepatrolled',
57 - 'tog-nolangconversion',
 57+ 'tog-variantconversion',
5858 'tog-ccmeonemails',
5959 'tog-diffonly',
6060 'tog-showhiddencats',
Index: trunk/phase3/maintenance/language/messageTypes.inc
@@ -165,7 +165,7 @@
166166 'sectionlink',
167167 'unit-pixel',
168168 'userrights-irreversible-marker',
169 - 'tog-nolangconversion',
 169+ 'tog-variantconversion',
170170 'tog-noconvertlink',
171171 'yourvariant',
172172 'variantname-zh-hans',
Index: trunk/phase3/skins/Vector.php
@@ -50,7 +50,7 @@
5151 */
5252 function buildNavigationUrls() {
5353 global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest;
54 - global $wgDisableLangConversion;
 54+ global $wgEnableVariants;
5555
5656 wfProfileIn( __METHOD__ );
5757
@@ -293,7 +293,7 @@
294294 // Gets list of language variants
295295 $variants = $wgContLang->getVariants();
296296 // Checks that language conversion is enabled and variants exist
297 - if( !$wgDisableLangConversion && count( $variants ) > 1 ) {
 297+ if( $wgEnableVariants && count( $variants ) > 1 ) {
298298 // Gets preferred variant
299299 $preferred = $wgContLang->getPreferredVariant();
300300 // Loops over each variant
Index: trunk/phase3/includes/Preferences.php
@@ -213,10 +213,10 @@
214214 'label-message' => 'yourlanguage',
215215 );
216216
217 - global $wgContLang, $wgDisableLangConversion;
 217+ global $wgContLang, $wgEnableVariants;
218218 /* see if there are multiple language variants to choose from*/
219219 $variantArray = array();
220 - if(!$wgDisableLangConversion) {
 220+ if($wgEnableVariants) {
221221 $variants = $wgContLang->getVariants();
222222
223223 $languages = Language::getLanguageNames( true );
@@ -245,7 +245,7 @@
246246 }
247247 }
248248
249 - if( count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion ) {
 249+ if( count($variantArray) > 1 && $wgEnableVariants && !$wgDisableTitleConversion ) {
250250 $defaultPreferences['noconvertlink'] =
251251 array(
252252 'type' => 'toggle',
Index: trunk/phase3/includes/SkinTemplate.php
@@ -818,9 +818,9 @@
819819 }
820820
821821 /* show links to different language variants */
822 - global $wgDisableLangConversion;
 822+ global $wgEnableVariants;
823823 $variants = $wgContLang->getVariants();
824 - if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
 824+ if( $wgEnableVariants && sizeof( $variants ) > 1 ) {
825825 $preferred = $wgContLang->getPreferredVariant();
826826 $vcount=0;
827827 foreach( $variants as $code ) {
@@ -1106,4 +1106,4 @@
11071107 $msg = $this->translator->translate( $str );
11081108 return ( $msg != '-' ) && ( $msg != '' ); # ????
11091109 }
1110 -}
\ No newline at end of file
 1110+}
Index: trunk/phase3/includes/Skin.php
@@ -1268,9 +1268,9 @@
12691269 function variantLinks() {
12701270 $s = '';
12711271 /* show links to different language variants */
1272 - global $wgDisableLangConversion, $wgLang, $wgContLang;
 1272+ global $wgEnableVariants, $wgLang, $wgContLang;
12731273 $variants = $wgContLang->getVariants();
1274 - if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
 1274+ if( $wgEnableVariants && sizeof( $variants ) > 1 ) {
12751275 foreach( $variants as $code ) {
12761276 $varname = $wgContLang->getVariantname( $code );
12771277 if( $varname == 'disable' )
Index: trunk/phase3/includes/DefaultSettings.php
@@ -887,7 +887,7 @@
888888 $wgCheckSerialized = true;
889889
890890 /** Whether to enable language variant conversion. */
891 -$wgDisableLangConversion = false;
 891+$wgEnableVariants = true;
892892
893893 /** Whether to enable language variant conversion for links. */
894894 $wgDisableTitleConversion = false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r51129follow up r51128, reverting special page aliases which was accidentally commi...shinjiman18:22, 28 May 2009
r51130follow up r51128, update more of RELEASE-NOTESshinjiman18:31, 28 May 2009
r51390follow up r51128, adding type check for $wgUser->getOption( 'variantconversio...shinjiman08:16, 3 June 2009
r51460Revert r51128, and its follow-up revisions r51129, r51130, r51390....werdna09:48, 4 June 2009

Comments

#Comment by Tim Starling (talk | contribs)   07:34, 3 June 2009

It's so totally broken that I can only assume it's untested. There's no default defined for the variantconversion user preference, so the default comes out of $wgUser->getOption() as null. LanguageConverter::parserConvert() then tests if null == 0, which it is, and so it sets $wgEnableVariants = false. This makes the variant links disappear from the tab list, and the variant preferences disappear from the Special:Preferences. $extraUserToggles doesn't appear to actually do anything in the new preferences system, so there's no way to turn the variant tabs back on. But they will come back on a parser cache hit, since LanguageConverter::parserConvert() is not called in that case and so $wgEnableVariants is true.

I was looking for parser cache pollution, which I'm quite sure is possible, but I couldn't get that far because the feature doesn't work at all.

Please revert these changes and anything else that is related. In the future, please test your code thoroughly before you commit it.

#Comment by Shinjiman (talk | contribs)   08:20, 3 June 2009

The type check had been added in r51390.

The $extraUserToggles variable on Special:Preferences is currently blocked by the bug 18870.

#Comment by Werdna (talk | contribs)   09:20, 4 June 2009

You missed the point, which was that you have to add a default for every preference, and that preference should default to true. Hacking in a special-case for "no preference" isn't the correct solution.

Seems to also include an unrelated change of name for a configuration variable. Don't do this, and if you do, include backwards-compatibility code.


#Comment by Werdna (talk | contribs)   09:50, 4 June 2009

Reverted in r51460.

Status & tagging log