Issue Bug Closed

#90925Incorrectly selected items in MM select fields

Sebastian Lechenbauer 04/01/20, 22:56 updated 04/21/20, 10:42

Description

After updating from TYPO3 9.5.14 to 9.5.15 there are incorrectly selected items in some of my backend select fields with MM relations.

I can reproduce this behaviour in 9.5.14 with a patch of change “2020-03-06 622e1a3dcd [BUGFIX] Reorder processing of TCA select items again”.

The function call in TcaSelectItems.php line 87:

$result['databaseRow'][$fieldName] = $this->processSelectFieldValue($result, $fieldName, $staticValues);
changed there to:
$result['databaseRow'][$fieldName] = $this->processSelectFieldValue($result, $fieldName, $itemArray);

$staticValues is empty, but $itemArray is filled in my case with all available items – and compared in AbstractDataProvider to the $currentDatabaseValueArray which holds the number of relations for MM select fields.

    protected function processSelectFieldValue(array $result, $fieldName, array $staticValues)
    {
        $fieldConfig = $result['processedTca']['columns'][$fieldName];

        $currentDatabaseValueArray = array_key_exists($fieldName, $result['databaseRow']) ? $result['databaseRow'][$fieldName] : [];
        $newDatabaseValueArray = [];

        // Add all values that were defined by static methods and do not come from the relation
        // e.g. TCA, TSconfig, itemProcFunc etc.
        foreach ($currentDatabaseValueArray as $value) {
            if (isset($staticValues[$value])) {
                $newDatabaseValueArray[] = $value;
            }
        }

As a result the MM select field gets as additional item the record with uid == number of relations, which can not be deleted.

Reviews 4