Currently, running composer phpunit -- extensions/CampaignEvents --filter "UtilsTest::testDiacriticInsensitiveSort" on my device results in two of the test-cases under testDiacriticInsensitiveSort failing:
$ composer phpunit -- extensions/CampaignEvents --filter "UtilsTest::testDiacriticInsensitiveSort" > Composer\Config::disableProcessTimeout Using PHP 8.3.30 Running with MediaWiki settings because there might be integration tests PHPUnit 9.6.21 by Sebastian Bergmann and contributors. .FF 3 / 3 (100%) Time: 00:00.187, Memory: 82.40 MB There were 2 failures: 1) MediaWiki\Extension\CampaignEvents\Tests\Unit\UtilsTest::testDiacriticInsensitiveSort with data set "diacritics" (array('Ǵermany', 'Ḟrance', 'Ĕngland'), array('Ĕngland', 'Ḟrance', 'Ǵermany')) Failed asserting that two arrays are identical. --- Expected +++ Actual @@ @@ Array &0 ( 'GB' => 'Ĕngland' + 'DE' => 'Ǵermany' 'FR' => 'Ḟrance' - 'DE' => 'Ǵermany' ) /[...]/extensions/CampaignEvents/tests/phpunit/unit/UtilsTest.php:130 2) MediaWiki\Extension\CampaignEvents\Tests\Unit\UtilsTest::testDiacriticInsensitiveSort with data set "mixed" (array('France', 'England', 'Ǵermany', 'Éngland'), array('England', 'Éngland', 'France', 'Ǵermany')) Failed asserting that two arrays are identical. --- Expected +++ Actual @@ @@ Array &0 ( + 'B' => 'Éngland' 'A' => 'England' - 'B' => 'Éngland' + 'D' => 'Ǵermany' 'C' => 'France' - 'D' => 'Ǵermany' ) /[...]/extensions/CampaignEvents/tests/phpunit/unit/UtilsTest.php:130
Copying the logic from Utils::diacriticInsensitiveSort into 3v4l.org, the sorting also doesn't work properly there, though in a different way to how it doesn't work for me locally:
array(3) {
["DE"]=>
string(8) "Ǵermany"
["GB"]=>
string(8) "Ĕngland"
["FR"]=>
string(8) "Ḟrance"
}The current logic in diacriticInsensitiveSort uses the PHP iconv function (e.g., iconv( 'UTF-8', 'ASCII//TRANSLIT//IGNORE', $a );). However, it seems like it might be a known issue that whether or not this function-call will work properly may depend on the exact iconv that's installed on a given system:
See also this StackOverflow question (which seems potentially relevant here). This comment on the PHP docs also seems like it could be relevant, but I haven't checked.
(Splitting this into a task from https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CampaignEvents/+/1203476/comment/c445e502_c4ee09e6/)