X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FCollation.php;h=7fa5c6e4772dfdb8930b20dd20006a635bf06d2c;hb=0e289eae349ce35d03af3e8fc10e9ad2e0119f26;hp=c1f0b3881a13ef328239189512bca2542726180d;hpb=d24b74ce2db24799dbaa2abe0277a48694ad2ebd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Collation.php b/includes/Collation.php index c1f0b3881a..7fa5c6e477 100644 --- a/includes/Collation.php +++ b/includes/Collation.php @@ -406,14 +406,15 @@ class IcuCollation extends Collation { } } - // Sort the letters. - // - // It's impossible to have the precompiled data file properly sorted, - // because the sort order changes depending on ICU version. If the - // array is not properly sorted, the binary search will return random - // results. - // - // We also take this opportunity to remove primary collisions. + /* Sort the letters. + * + * It's impossible to have the precompiled data file properly sorted, + * because the sort order changes depending on ICU version. If the + * array is not properly sorted, the binary search will return random + * results. + * + * We also take this opportunity to remove primary collisions. + */ $letterMap = array(); foreach ( $letters as $letter ) { $key = $this->getPrimarySortKey( $letter ); @@ -428,38 +429,40 @@ class IcuCollation extends Collation { } } ksort( $letterMap, SORT_STRING ); - // Remove duplicate prefixes. Basically if something has a sortkey - // which is a prefix of some other sortkey, then it is an - // expansion and probably should not be considered a section - // header. - // - // For example 'þ' is sometimes sorted as if it is the letters - // 'th'. Other times it is its own primary element. Another - // example is '₨'. Sometimes its a currency symbol. Sometimes it - // is an 'R' followed by an 's'. - // - // Additionally an expanded element should always sort directly - // after its first element due to they way sortkeys work. - // - // UCA sortkey elements are of variable length but no collation - // element should be a prefix of some other element, so I think - // this is safe. See: - // * https://ssl.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm - // * http://site.icu-project.org/design/collation/uca-weight-allocation - // - // Additionally, there is something called primary compression to - // worry about. Basically, if you have two primary elements that - // are more than one byte and both start with the same byte then - // the first byte is dropped on the second primary. Additionally - // either \x03 or \xFF may be added to mean that the next primary - // does not start with the first byte of the first primary. - // - // This shouldn't matter much, as the first primary is not - // changed, and that is what we are comparing against. - // - // tl;dr: This makes some assumptions about how icu implements - // collations. It seems incredibly unlikely these assumptions - // will change, but nonetheless they are assumptions. + + /* Remove duplicate prefixes. Basically if something has a sortkey + * which is a prefix of some other sortkey, then it is an + * expansion and probably should not be considered a section + * header. + * + * For example 'þ' is sometimes sorted as if it is the letters + * 'th'. Other times it is its own primary element. Another + * example is '₨'. Sometimes its a currency symbol. Sometimes it + * is an 'R' followed by an 's'. + * + * Additionally an expanded element should always sort directly + * after its first element due to they way sortkeys work. + * + * UCA sortkey elements are of variable length but no collation + * element should be a prefix of some other element, so I think + * this is safe. See: + * - https://ssl.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm + * - http://site.icu-project.org/design/collation/uca-weight-allocation + * + * Additionally, there is something called primary compression to + * worry about. Basically, if you have two primary elements that + * are more than one byte and both start with the same byte then + * the first byte is dropped on the second primary. Additionally + * either \x03 or \xFF may be added to mean that the next primary + * does not start with the first byte of the first primary. + * + * This shouldn't matter much, as the first primary is not + * changed, and that is what we are comparing against. + * + * tl;dr: This makes some assumptions about how icu implements + * collations. It seems incredibly unlikely these assumptions + * will change, but nonetheless they are assumptions. + */ $prev = false; $duplicatePrefixes = array(); @@ -505,7 +508,7 @@ class IcuCollation extends Collation { // Save to cache $this->firstLetterData = $data; - $cache->set( $cacheKey, $data, 86400 * 7 /* 1 week */ ); + $cache->set( $cacheKey, $data, $cache::TTL_WEEK ); return $data; }