Issue Bug Closed

#94549Flexform section change order when deleting item

Paul Kamma 07/13/21, 10:14 updated 10/23/23, 11:59

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?

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.