r99292 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99291‎ | r99292 | r99293 >
Date:00:37, 8 October 2011
Author:brion
Status:ok
Tags:
Comment:
MFT r99289, r99290: rolls back Turkish uc()/lc() support for dotless/dotted i: breaks Special pages, magic words case-insensitive matching that's done by lowercasing things (bug 31490)
Modified paths:
  • /branches/wmf/1.18wmf1/languages/classes/LanguageTr.php (modified) (history)
  • /branches/wmf/1.18wmf1/tests/parser/parserTests.txt (modified) (history)
  • /branches/wmf/1.18wmf1/tests/phpunit/languages/LanguageTrTest.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/tests/phpunit/languages/LanguageTrTest.php
@@ -16,40 +16,13 @@
1717 unset( $this->lang );
1818 }
1919
20 -##### Full Turkish alphabet #################################################
21 -
22 - function testLowerCaseTurkishAlphabetToUppercase() {
23 - $this->assertEquals( 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ',
24 - $this->lang->uc( 'abcçdefgğhıijklmnoöprsştuüvyz' ),
25 - 'Lower case Turkish alphabet to upper case'
26 - );
27 - }
28 - function testUpperCaseTurkishAlphabetToUppercase() {
29 - $this->assertEquals( 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ',
30 - $this->lang->uc( 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ' ),
31 - 'Upper case Turkish alphabet to upper case'
32 - );
33 - }
34 - function testUpperCaseTurkishAlphabetToLowercase() {
35 - $this->assertEquals( 'abcçdefgğhıijklmnoöprsştuüvyz',
36 - $this->lang->lc( 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ' ),
37 - 'Upper case Turkish alphabet to lower case'
38 - );
39 - }
40 - function testLowerCaseTurkishAlphabetToLowercase() {
41 - $this->assertEquals( 'abcçdefgğhıijklmnoöprsştuüvyz',
42 - $this->lang->lc( 'abcçdefgğhıijklmnoöprsştuüvyz' ),
43 - 'Lower case Turkish alphabet to lower case'
44 - );
45 - }
46 -
4720 /**
4821 * See @bug 28040
4922 * Credits to #wikipedia-tr users berm, []LuCkY[] and Emperyan
5023 * @see http://en.wikipedia.org/wiki/Dotted_and_dotless_I
5124 * @dataProvider provideDottedAndDotlessI
5225 */
53 - function testChangeCaseOfFirstCharBeingDottedAndDotlessI( $func, $input, $inputCase, $expected ) {
 26+ function testDottedAndDotlessI( $func, $input, $inputCase, $expected ) {
5427 if( $func == 'ucfirst' ) {
5528 $res = $this->lang->ucfirst( $input );
5629 } elseif( $func == 'lcfirst' ) {
@@ -87,60 +60,6 @@
8861 array( 'lcfirst', 'IPhone', 'upper', 'ıPhone' ),
8962
9063 );
91 - }
92 -
93 -##### LanguageTr specificities #############################################
94 - /**
95 - * @cover LanguageTr:lc
96 - * See @bug 28040
97 - */
98 - function testLanguageTrLowerCasingOverride() {
99 - $this->assertEquals( 'ııııı', $this->lang->lc( 'IIIII') );
10064 }
101 - /**
102 - * @cover LanguageTr:uc
103 - * See @bug 28040
104 - */
105 - function testLanguageTrUpperCasingOverride() {
106 - $this->assertEquals( 'İİİİİ', $this->lang->uc( 'iiiii') );
107 - }
10865
109 -##### Upper casing a string #################################################
110 - /**
111 - * Generic test for the Turkish dotted and dotless I strings
112 - * See @bug 28040
113 - * @dataProvider provideUppercaseStringsWithDottedAndDotlessI
114 - */
115 - function testUpperCasingOfAStringWithDottedAndDotLessI( $expected, $input ) {
116 - $this->assertEquals( $expected, $this->lang->uc( $input ) );
117 - }
118 - function provideUppercaseStringsWithDottedAndDotlessI() {
119 - return array(
120 - # expected, input string to uc()
121 - array( 'IIIII', 'ııııı' ),
122 - array( 'IIIII', 'IIIII' ), #identity
123 - array( 'İİİİİ', 'iiiii' ), # Specifically handled by LanguageTr:uc
124 - array( 'İİİİİ', 'İİİİİ' ), #identity
125 - );
126 - }
127 -
128 -##### Lower casing a string #################################################
129 - /**
130 - * Generic test for the Turkish dotted and dotless I strings
131 - * See @bug 28040
132 - * @dataProvider provideLowercaseStringsWithDottedAndDotlessI
133 - */
134 - function testLowerCasingOfAStringWithDottedAndDotLessI( $expected, $input ) {
135 - $this->assertEquals( $expected, $this->lang->lc( $input ) );
136 - }
137 - function provideLowercaseStringsWithDottedAndDotlessI() {
138 - return array(
139 - # expected, input string to lc()
140 - array( 'ııııı', 'IIIII' ), # Specifically handled by LanguageTr:lc
141 - array( 'ııııı', 'ııııı' ), #identity
142 - array( 'iiiii', 'İİİİİ' ),
143 - array( 'iiiii', 'iiiii' ), #identity
144 - );
145 - }
146 -
14766 }
Index: branches/wmf/1.18wmf1/tests/parser/parserTests.txt
@@ -8716,6 +8716,61 @@
87178717 !! end
87188718
87198719
 8720+!! test
 8721+Bug31490 Turkish: ucfirst 'blah'
 8722+!! options
 8723+language=tr
 8724+!! input
 8725+{{ucfirst:blah}}
 8726+!! result
 8727+<p>Blah
 8728+</p>
 8729+!! end
 8730+
 8731+!! test
 8732+Bug31490 Turkish: ucfirst 'ix'
 8733+!! options
 8734+language=tr
 8735+!! input
 8736+{{ucfirst:ix}}
 8737+!! result
 8738+<p>İx
 8739+</p>
 8740+!! end
 8741+
 8742+!! test
 8743+Bug31490 Turkish: lcfirst 'BLAH'
 8744+!! options
 8745+language=tr
 8746+!! input
 8747+{{lcfirst:BLAH}}
 8748+!! result
 8749+<p>bLAH
 8750+</p>
 8751+!! end
 8752+
 8753+!! test
 8754+Bug31490 Turkish: ucfırst (with a dotless i)
 8755+!! options
 8756+language=tr
 8757+!! input
 8758+{{ucfırst:blah}}
 8759+!! result
 8760+<p><a href="https://www.mediawiki.org/index.php?title=%C5%9Eablon:Ucf%C4%B1rst:blah&amp;action=edit&amp;redlink=1" class="new" title="Şablon:Ucfırst:blah (sayfa mevcut değil)">Şablon:Ucfırst:blah</a>
 8761+</p>
 8762+!! end
 8763+
 8764+!! test
 8765+Bug31490 ucfırst (with a dotless i) with English language
 8766+!! options
 8767+language=en
 8768+!! input
 8769+{{ucfırst:blah}}
 8770+!! result
 8771+<p><a href="https://www.mediawiki.org/index.php?title=Template:Ucf%C4%B1rst:blah&amp;action=edit&amp;redlink=1" class="new" title="Template:Ucfırst:blah (page does not exist)">Template:Ucfırst:blah</a>
 8772+</p>
 8773+!! end
 8774+
87208775 TODO:
87218776 more images
87228777 more tables
Index: branches/wmf/1.18wmf1/languages/classes/LanguageTr.php
@@ -36,46 +36,4 @@
3737 }
3838 }
3939
40 - /**
41 - * @see bug 28040
42 - *
43 - * @param $string string
44 - * @param $first string|bool
45 - *
46 - * @return string
47 - */
48 - function uc( $string, $first = false ) {
49 - if ( strlen( $string ) ) {
50 - if ( $first ) {
51 - if ( $string[0] === 'i' ) {
52 - $string = 'İ' . substr( $string, 1 );
53 - }
54 - } else {
55 - $string = str_replace( 'i', 'İ', $string );
56 - }
57 - }
58 - return parent::uc( $string, $first );
59 - }
60 -
61 - /**
62 - * @see bug 28040
63 - *
64 - * @param $string string
65 - * @param $first string|bool
66 - *
67 - * @return string
68 - */
69 - function lc( $string, $first = false ) {
70 - if ( strlen( $string ) ) {
71 - if ( $first ) {
72 - if ( $string[0] == 'I' ) {
73 - $string = 'ı' . substr( $string, 1 );
74 - }
75 - } else {
76 - $string = str_replace( 'I', 'ı', $string );
77 - }
78 - }
79 - return parent::lc( $string, $first );
80 - }
81 -
8240 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99246Tests for bug 31490 : turkish magic word with a 'i' are broken :d...hashar20:18, 7 October 2011
r99289followup r99246: fixes for test casesbrion00:27, 8 October 2011
r99290Revert r84057, r84080, part of r99074: lc() and uc() custom handling for Turk...brion00:30, 8 October 2011
r99291MFT r99289, r99290: rolls back Turkish uc()/lc() support for dotless/dotted i...brion00:36, 8 October 2011

Status & tagging log