Project

General

Profile

Actions

Bug #105015

closed

Locale aware sorting of foreign records with selectMultipleSideBySide in the backend

Added by Rémi Payette 2 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2024-09-17
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
13
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

in typo3 v10 and v13, I use a selectMultipleSideBySide to which I set sortItems in the TCA :

'thecolumn' => [
  'exclude' => 0,
  'label' => 'LLL:EXT:my_ext/Resources/Private/Language/locallang.xlf:sources',
  'config' => [
    'type' => 'select',
    'sortItems' => [
      'label' => 'asc',
    ],
    'renderType' => 'selectMultipleSideBySide',

The sort order is managed by the PHP function strcasecmp which only does basic ascii comparision which put accented characters at the end of the list.

This is what I have done locally to fix this ( sorry, not equipped to do a proper pull request )

typo3 10.4.45 /backend/Classes/Form/FormDataProvider/TcaSelectItems.php line 288
typo3 13.2.1 /cms-backend/Classes/Form/Processor/SelectItemProcessor.php line 159

    protected function sortItems(array $items, array $sortOrders): array
    {
        foreach ($sortOrders as $order => $direction) {
            switch ($order) {
                case 'label':
                    $direction = strtolower($direction);
*                   $collator = new \Collator(null);
                    @usort(
                        $items,
*                       function ($item1, $item2) use ($direction, $collator) {
                            if ($direction === 'desc') {
*                               return $collator->compare($item1[0], $item2[0]) <= 0;
                            }
*                           return $collator->compare($item1[0], $item2[0]);
                        }
                    );
                    break;

This is the first half of the function in typo3 v10, same changes to the other case 'value'.
It's almost the same on typo3 v13.


Related issues 1 (0 open1 closed)

Is duplicate of TYPO3 Core - Bug #95575: Built-in sortItems by "label" does not respect UTF-8Closed2021-10-12

Actions
Actions #1

Updated by Garvin Hicking 2 months ago

  • Category changed from Backend User Interface to FormEngine aka TCEforms
Actions #2

Updated by Andreas Kienast about 2 months ago

  • Status changed from New to Accepted
Actions #3

Updated by Gerrit Code Review about 2 months ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86443

Actions #4

Updated by Rémi Payette about 2 months ago

I think the second case on line 176 :

case 'value':

should also use the \Collator class to do it's comparisons

Actions #5

Updated by Gerrit Code Review about 2 months ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86443

Actions #6

Updated by Gerrit Code Review about 1 month ago

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86552

Actions #7

Updated by Anonymous about 1 month ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #8

Updated by Benni Mack about 1 month ago

  • Status changed from Resolved to Closed
Actions #9

Updated by S P about 1 month ago

  • Is duplicate of Bug #95575: Built-in sortItems by "label" does not respect UTF-8 added
Actions

Also available in: Atom PDF