Lists with items containing non-ascii characters are not sorted correctly

Created on 12 May 2014, over 10 years ago
Updated 15 January 2023, almost 2 years ago

Many efforts have been made to make Drupal 8 a great multilingual system. However, content types are never properly sorted when translations contain accentuated characters.

Content types are sorted using asort. Maybe we could set the locale beforehand.

Steps to reproduce:

Install Drupal 8
Enable the following modules

  • Configuration Translation
  • Content Translation
  • Interface Translation
  • Language

Add a language (French in the example)
Add a two content types (Show and Zone)
Translate the Show content type to ร‰mission
Switch languages (fr/admin/structure/types)

Expected behavior

To have a list in this order

  • Article
  • Basic page
  • ร‰mission
  • Zone

What happened instead

List was in this order:

  • Article
  • Basic page
  • Zone
  • ร‰mission
๐Ÿ› Bug report
Status

Needs review

Version

10.1 โœจ

Component
Language systemย  โ†’

Last updated 6 days ago

  • Maintained by
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany @sun
Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada nlambert

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to RTBC almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ameymudras

    Tested on 10.1.x and following is my observation

    1. The issue summary is clear and explains the overall problem
    2. Testing steps have been provided and was able to reproduce the issue
    3. Patch #24 applies cleanly and the non-ASCII config entity sort correctly
    4. Tests have been included and passes for #24
    5. Did code review and no issues were identified

    Marking this as RTBC, not including additional screenshots. Already provided in #27

  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK
    +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
    @@ -226,14 +226,22 @@ public function createDuplicate() {
    +      $language_id = \Drupal::service('language_manager')
    ...
    +      $a_label = \Drupal::service('transliteration')->transliterate(
    ...
    +      $b_label = \Drupal::service('transliteration')->transliterate(
    

    A bit concerned about calling all these services inside the sort callback, because it feels like this is not going to be very performant in a case when there are hundreds of items or more to sort.

    We could at least extract the transliteration service to a variable, and also skip transliterating the empty string if it is falsy? Is there a way of injecting at least the language ID, given that it never changes, or the transliteration service itself?

    Also, do we have the same concerns about sorting in different languages as was raised in #3262017-90: Country list is not correctly sorted when it's localized with accents (e.g. German, Turkish) โ†’ ? Is transliterating the right thing to do in all cases?

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner

    @longwave : I remove transliteration and added the Collator like in ๐Ÿ› Country list is not correctly sorted when it's localized with accents (e.g. German, Turkish) Postponed .

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner

    To prevent MethodArgumentValueNotImplemented exception in Collator, language_id en is used if intl extension is not installed.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    The new polyfill and intl extension have the same considerations as ๐Ÿ› Country list is not correctly sorted when it's localized with accents (e.g. German, Turkish) Postponed so this will need to wait for the decision over there first.

  • last update over 1 year ago
    29,277 pass, 2 fail
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner

    Reroll

  • last update over 1 year ago
    29,300 pass
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner
  • Status changed to Postponed over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Also posted to the #needs-review-queue-initative slack channel so hopefully a framework manager can take a look at that one.

  • last update over 1 year ago
    Patch Failed to Apply
  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner

    Unpostpone it. ๐Ÿ› Country list is not correctly sorted when it's localized with accents (e.g. German, Turkish) Postponed is postponed because nobody wants to break the API.

  • Pipeline finished with Failed
    10 months ago
    Total: 172s
    #109189
  • Pipeline finished with Failed
    10 months ago
    Total: 178s
    #109190
  • Pipeline finished with Failed
    10 months ago
    #109196
  • Pipeline finished with Failed
    10 months ago
    Total: 553s
    #109197
  • Pipeline finished with Failed
    10 months ago
    #109205
  • Pipeline finished with Canceled
    10 months ago
    Total: 491s
    #109219
  • Pipeline finished with Failed
    10 months ago
    Total: 487s
    #109228
  • Pipeline finished with Failed
    10 months ago
    Total: 483s
    #109240
  • Pipeline finished with Failed
    10 months ago
    #109257
  • Pipeline finished with Failed
    10 months ago
    Total: 479s
    #109260
  • Pipeline finished with Failed
    10 months ago
    Total: 183s
    #109281
  • Pipeline finished with Running
    10 months ago
    #109285
  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner

    Converted to MR

  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Can the issue summary be updated to use the standard template please.

    Hiding all patches for clarity as fix is in MR now.

    Will need framework manager review for the package being added.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner
  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner
  • Status changed to Needs work 8 months ago
  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • Pipeline finished with Failed
    8 months ago
    Total: 134s
    #178482
  • Pipeline finished with Success
    7 months ago
    Total: 180s
    #191129
  • Pipeline finished with Failed
    7 months ago
    Total: 338s
    #191128
  • Pipeline finished with Failed
    7 months ago
    #191123
  • Pipeline finished with Failed
    7 months ago
    Total: 504s
    #191422
  • Pipeline finished with Failed
    7 months ago
    Total: 553s
    #191438
  • Pipeline finished with Success
    7 months ago
    Total: 512s
    #191445
  • Status changed to Needs review 7 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner
  • Status changed to Needs work 7 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Took a look at the MR before pinging a framework manager and seems we are updating several packages that seem unrelated to this. Can those be reverted please.

  • Pipeline finished with Success
    7 months ago
    Total: 512s
    #195761
  • Pipeline finished with Success
    7 months ago
    Total: 537s
    #195792
  • Status changed to Needs review 7 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner
  • Status changed to Needs work 7 months ago
  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • Pipeline finished with Success
    7 months ago
    Total: 619s
    #199928
  • Status changed to Needs review 7 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner

    Rerolled again

  • Status changed to RTBC 6 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    I can't make the call about the new package but the MR does fix the problem described in the issue summary. Moving to RTBC to put in front of the framework managers.

  • Status changed to Needs work 6 months ago
  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • Pipeline finished with Canceled
    6 months ago
    Total: 63s
    #221033
  • Pipeline finished with Failed
    6 months ago
    Total: 458s
    #221034
  • Pipeline finished with Success
    6 months ago
    Total: 502s
    #221056
  • Status changed to RTBC 6 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner

    Rerolled again

  • Status changed to Needs work 6 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    It's fine to add a new Symfony polyfill, (more a release management decision than a framework one) but there should really be a dependency evaluation in the issue summary here per https://www.drupal.org/about/core/policies/core-dependency-policies/depe... โ†’ - can be very short because we know the answers in this case.

  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner

    Dependency evaluation added to issue summary

  • Status changed to Needs work 5 months ago
  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner
  • Status changed to RTBC 5 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Remarking as dependency eval has been added to summary.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    I read the IS, comments and the MR. The only possible thing to consider is @longwave's point in #31 about calling services inside the sort callback "is not going to be very performant in a case when there are hundreds of items or more to sort". The transliteration service was removed from an earlier iteration of the MR but is still is getting the LanguageManager.

    Leaving at RTBC.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone
  • Status changed to Needs work 2 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    #31 still to be addressed.
    MR no longer applies in the meantime.

  • Pipeline finished with Canceled
    2 months ago
    Total: 349s
    #316419
  • Pipeline finished with Failed
    2 months ago
    #316424
  • Pipeline finished with Failed
    2 months ago
    Total: 190s
    #316435
  • Pipeline finished with Failed
    2 months ago
    Total: 167s
    #316439
  • Pipeline finished with Failed
    2 months ago
    Total: 284s
    #317325
  • Pipeline finished with Failed
    2 months ago
    Total: 124s
    #317366
  • Pipeline finished with Failed
    2 months ago
    Total: 330s
    #317374
  • Pipeline finished with Failed
    2 months ago
    Total: 187s
    #317383
  • Pipeline finished with Failed
    2 months ago
    Total: 330s
    #317385
  • Pipeline finished with Failed
    2 months ago
    Total: 475s
    #317392
  • Pipeline finished with Failed
    2 months ago
    Total: 233s
    #317405
  • Pipeline finished with Failed
    2 months ago
    Total: 171s
    #317417
  • Pipeline finished with Failed
    2 months ago
    Total: 741s
    #317513
  • Pipeline finished with Failed
    2 months ago
    Total: 154s
    #317548
  • Pipeline finished with Failed
    2 months ago
    Total: 163s
    #317565
  • Pipeline finished with Failed
    2 months ago
    Total: 542s
    #317567
  • Pipeline finished with Canceled
    2 months ago
    Total: 672s
    #317590
  • Pipeline finished with Success
    2 months ago
    Total: 391s
    #317595
  • Pipeline finished with Failed
    2 months ago
    Total: 790s
    #317600
  • Pipeline finished with Failed
    2 months ago
    Total: 322s
    #317612
  • Pipeline finished with Failed
    2 months ago
    Total: 130s
    #317614
  • Pipeline finished with Failed
    2 months ago
    #317618
  • Pipeline finished with Failed
    2 months ago
    Total: 673s
    #317624
  • Pipeline finished with Failed
    2 months ago
    Total: 684s
    #317662
  • Pipeline finished with Failed
    2 months ago
    Total: 186s
    #317671
  • Pipeline finished with Failed
    2 months ago
    Total: 200s
    #317673
  • Pipeline finished with Failed
    2 months ago
    Total: 203s
    #317677
  • Pipeline finished with Failed
    2 months ago
    Total: 204s
    #317679
  • Pipeline finished with Failed
    2 months ago
    Total: 638s
    #317682
  • Pipeline finished with Failed
    2 months ago
    Total: 636s
    #317690
  • Pipeline finished with Success
    2 months ago
    Total: 1029s
    #318009
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner

    The service is moved to a new function

    public static function sortEntities(array &$entities): bool
    

    which calls a new compare function public static function compare(ConfigEntityInterface $a, ConfigEntityInterface $b, \Collator $collator): int.
    The sort functionpublic static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) is now deprecated in all child classes.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    appears to have merge conflict but the tag no-needs-review-bot kept the bot from getting it.

  • Pipeline finished with Canceled
    2 months ago
    Total: 74s
    #327857
  • Pipeline finished with Failed
    2 months ago
    Total: 599s
    #327859
  • Pipeline finished with Success
    2 months ago
    Total: 747s
    #327880
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sleitner

    Rerolled

Production build 0.71.5 2024