static::class,
$this->locale,
$this->digitTransformLanguage->getCode(),
- self::getICUVersion(),
+ INTL_ICU_VERSION,
self::FIRST_LETTER_VERSION
);
$this->firstLetterData = $cache->getWithSetCallback( $cacheKey, $cache::TTL_WEEK, function () {
foreach ( $letters as $letter ) {
$key = $this->getPrimarySortKey( $letter );
if ( isset( $letterMap[$key] ) ) {
- // Primary collision
- // Keep whichever one sorts first in the main collator
- if ( $this->mainCollator->compare( $letter, $letterMap[$key] ) < 0 ) {
+ // Primary collision (two characters with the same sort position).
+ // Keep whichever one sorts first in the main collator.
+ $comp = $this->mainCollator->compare( $letter, $letterMap[$key] );
+ wfDebug( "Primary collision '$letter' '{$letterMap[$key]}' (comparison: $comp)\n" );
+ // If that also has a collision, use codepoint as a tiebreaker.
+ if ( $comp === 0 ) {
+ // TODO Use <=> operator when PHP 7 is allowed.
+ $comp = UtfNormal\Utils::utf8ToCodepoint( $letter ) -
+ UtfNormal\Utils::utf8ToCodepoint( $letterMap[$key] );
+ }
+ if ( $comp < 0 ) {
$letterMap[$key] = $letter;
}
} else {
* can't be determined.
*
* The constant INTL_ICU_VERSION this function refers to isn't really
- * documented. It is available since PHP 5.3.7 (see PHP 54561
- * https://bugs.php.net/bug.php?id=54561). This function will return
- * false on older PHPs.
- *
- * TODO: Remove the backwards-compatibility as MediaWiki now requires
- * higher levels of PHP.
+ * documented, but see https://bugs.php.net/bug.php?id=54561.
*
* @since 1.21
- * @return string|bool
+ * @deprecated since 1.32, use INTL_ICU_VERSION directly
+ * @return string
*/
static function getICUVersion() {
- return defined( 'INTL_ICU_VERSION' ) ? INTL_ICU_VERSION : false;
+ return INTL_ICU_VERSION;
}
/**
* @return string|bool
*/
static function getUnicodeVersionForICU() {
- $icuVersion = self::getICUVersion();
+ $icuVersion = INTL_ICU_VERSION;
if ( !$icuVersion ) {
return false;
}
$versionPrefix = substr( $icuVersion, 0, 3 );
// Source: http://site.icu-project.org/download
$map = [
+ '61.' => '10.0',
+ '60.' => '10.0',
'59.' => '9.0',
'58.' => '9.0',
'57.' => '8.0',