Remove everything related to CollationFa

This workaround was needed when ICU in production was broken
but after T189295 this is not needed anymore and we switched off
this collation from all Persian Wikis already

Bug: T139110
Change-Id: Ifad89555b6ac96a3eb36ca24b55e1f8ee57a1f05
This commit is contained in:
Amir Sarabadani 2018-05-18 16:44:18 +02:00
parent 369476d30e
commit 5a21de8abb
5 changed files with 1 additions and 118 deletions

View file

@ -109,6 +109,7 @@ because of Phabricator reports.
* Overriding SearchEngine::{searchText,searchTitle,searchArchiveTitle}
in extending classes is deprecated. Extend related doSearch* methods
instead.
* CollationFa has been removed completely as it's not needed anymore
=== Other changes in 1.32 ===
* …

View file

@ -280,7 +280,6 @@ $wgAutoloadLocalClasses = [
'Collation' => __DIR__ . '/includes/collation/Collation.php',
'CollationCkb' => __DIR__ . '/includes/collation/CollationCkb.php',
'CollationEt' => __DIR__ . '/includes/collation/CollationEt.php',
'CollationFa' => __DIR__ . '/includes/collation/CollationFa.php',
'CommandLineInc' => __DIR__ . '/maintenance/commandLine.inc',
'CommandLineInstaller' => __DIR__ . '/maintenance/install.php',
'CommentStore' => __DIR__ . '/includes/CommentStore.php',

View file

@ -63,8 +63,6 @@ abstract class Collation {
return new CollationCkb;
case 'xx-uca-et':
return new CollationEt;
case 'xx-uca-fa':
return new CollationFa;
case 'uppercase-ab':
return new AbkhazUppercaseCollation;
case 'uppercase-ba':

View file

@ -1,60 +0,0 @@
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
/**
* Temporary workaround for incorrect collation of Persian language ('fa') in ICU 52 (bug T139110).
*
* Replace with other letters that appear in an okish spot in the alphabet
*
* - Characters 'و' 'ا' (often appear at the beginning of words)
* - Characters 'ٲ' 'ٳ' (may appear at the beginning of words in loanwords)
*
* @since 1.29
*/
class CollationFa extends IcuCollation {
// Really hacky - replace with stuff from other blocks.
private $override = [
// U+0627 ARABIC LETTER ALEF => U+0623 ARABIC LETTER ALEF WITH HAMZA ABOVE
"\xd8\xa7" => "\xd8\xa3",
// U+0648 ARABIC LETTER WAW => U+0649 ARABIC LETTER ALEF MAKSURA
"\xd9\x88" => "\xd9\x89",
// U+0672 ARABIC LETTER ALEF WITH WAVY HAMZA ABOVE => U+F3001 (private use area)
"\xd9\xb2" => "\xF3\xB3\x80\x81",
// U+0673 ARABIC LETTER ALEF WITH WAVY HAMZA BELOW => U+F3002 (private use area)
"\xd9\xb3" => "\xF3\xB3\x80\x82",
];
public function __construct() {
parent::__construct( 'fa' );
}
public function getSortKey( $string ) {
$modified = strtr( $string, $this->override );
return parent::getSortKey( $modified );
}
public function getFirstLetter( $string ) {
if ( isset( $this->override[substr( $string, 0, 2 )] ) ) {
return substr( $string, 0, 2 );
}
return parent::getFirstLetter( $string );
}
}

View file

@ -1,55 +0,0 @@
<?php
/**
* @covers CollationFa
*/
class CollationFaTest extends MediaWikiTestCase {
/*
* The ordering is a weird hack designed to work only with a very
* specific version of libicu, and as such can't really be unit tested
* against a random version of libicu
*/
public function setUp() {
parent::setUp();
$this->checkPHPExtension( 'intl' );
}
/**
* @dataProvider provideGetFirstLetter
*/
public function testGetFirstLetter( $letter, $str ) {
$coll = new CollationFa;
$this->assertEquals( $letter, $coll->getFirstLetter( $str ), $str );
}
public function provideGetFirstLetter() {
return [
[
'۷',
'۷'
],
[
'ا',
'ا'
],
[
'ا',
'ایران'
],
[
'ب',
'برلین'
],
[
'و',
'واو'
],
[ "\xd8\xa7", "\xd8\xa7Foo" ],
[ "\xd9\x88", "\xd9\x88Foo" ],
[ "\xd9\xb2", "\xd9\xb2Foo" ],
[ "\xd9\xb3", "\xd9\xb3Foo" ],
];
}
}