Project

General

Profile

Actions

Bug #94549

closed

Flexform section change order when deleting item

Added by Paul Kamma almost 3 years ago. Updated 7 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend API
Target version:
-
Start date:
2021-07-13
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.4
Tags:
flexform asort section order save
Complexity:
Is Regression:
Sprint Focus:

Description

I've discoverd an odd behaviour with FlexForms in combination with sections. When a section contains at least 17 Items and (After a save) a item is removed and then saved then the order is changed of the items.

I tried to find the root of this behaviour and ended in the DataHandler

https://github.com/TYPO3/TYPO3.CMS/blob/10.4/typo3/sysext/core/Classes/DataHandling/DataHandler.php#L2336

The asort cause the isse but I don't know why. I made some independent tests with the data which gets passed to the method and noticed something.

$data = [
   "60ed404104921816320239" => "",
   "60ed524b3b735029561451" => "",
   "60ed56d915a2d143366883" => "",
   "60ed550b0146a452956314" => "",
   "60ed523e70373667109521" => "",
   "60ed5241903ef623057117" => "",
   "60ed5243d6b64443066657" => "",
   "60ed5246a244d957906702" => "",
   "60ed5248d9115418847870" => "",
   "60ed404526917612536689" => "",
   "60ed52531e488403102629" => "",
   "60ed525043157609282528" => "",
   "60ed52551e75e407845160" => "",
   "60ed525714df1794924549" => "",
   "60ed52591c447113268801" => "",
   "60ed525ad7160719857266" => "DELETE",
];

asort($data);
print_r($data);

//Output
Array
(
    [60ed404104921816320239] => 
    [60ed524b3b735029561451] => 
    [60ed56d915a2d143366883] => 
    [60ed550b0146a452956314] => 
    [60ed523e70373667109521] => 
    [60ed5241903ef623057117] => 
    [60ed5243d6b64443066657] => 
    [60ed5246a244d957906702] => 
    [60ed5248d9115418847870] => 
    [60ed404526917612536689] => 
    [60ed52531e488403102629] => 
    [60ed525043157609282528] => 
    [60ed52551e75e407845160] => 
    [60ed525714df1794924549] => 
    [60ed52591c447113268801] => 
    [60ed525ad7160719857266] => DELETE
)

The Order is correct, now lets try the same with one item more:

$data2 = [
   "60ed404104921816320239" => "",
   "60ed524b3b735029561451" => "",
   "60ed56d915a2d143366883" => "",
   "60ed550b0146a452956314" => "",
   "60ed523e70373667109521" => "",
   "60ed5241903ef623057117" => "",
   "60ed5243d6b64443066657" => "",
   "60ed5246a244d957906702" => "",
   "60ed5248d9115418847870" => "",
   "60ed404526917612536689" => "",
   "60ed52531e488403102629" => "",
   "60ed525043157609282528" => "",
   "60ed52551e75e407845160" => "",
   "60ed525714df1794924549" => "",
   "60ed52591c447113268801" => "",
   "60ed57dcde329615532849" => "",
   "60ed57e02d30b476661246" => "DELETE",
];

asort($data2);
print_r($data2);

//Output
Array
(
    [60ed404104921816320239] => 
    [60ed404526917612536689] => 
    [60ed57dcde329615532849] => 
    [60ed52591c447113268801] => 
    [60ed525714df1794924549] => 
    [60ed52551e75e407845160] => 
    [60ed525043157609282528] => 
    [60ed52531e488403102629] => 
    [60ed5248d9115418847870] => 
    [60ed524b3b735029561451] => 
    [60ed5246a244d957906702] => 
    [60ed5243d6b64443066657] => 
    [60ed5241903ef623057117] => 
    [60ed523e70373667109521] => 
    [60ed550b0146a452956314] => 
    [60ed56d915a2d143366883] => 
    [60ed57e02d30b476661246] => DELETE
)

You notice that many items are not in the correct order as the input.

Wo why did this happen? Is the asort event required?


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Task #99952: Avoid GU::_GP() in DataHandlerClosed2023-02-14

Actions
Actions

Also available in: Atom PDF