Bug #90925
closedIncorrectly selected items in MM select fields
100%
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.
Updated by Benni Mack almost 5 years ago
- Related to Bug #85142: Recent reordering of TCA select items processing makes it impossible to post-process foreign_table items added
Updated by Joschi Kuphal almost 5 years ago
- TYPO3 Version changed from 9 to 10
I can confirm similar behaviour for 10.3, but I didn't have the chance to investigate further by now.
Respectively: As soon as the additional record gets saved along with the real selection, the number of MM records increases by one, which potentially adds another record and so on. The erroneous records can be deleted though (but get re-added as soon as the form reloads).
Updated by Martin Weymayer almost 5 years ago
Same problem occurs, if you use itemsProcFunc and fill selectable items with custom database query. The item with the "id" of number of selected items is also added to selected and you can not delete it. So for example if you have added product with id 5,6,7 and 8, the product with id 4 is also added to selected. This bug is already since 7.6
Updated by Gerrit Code Review almost 5 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/64059
Updated by Gerrit Code Review almost 5 years ago
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/64062
Updated by Gerrit Code Review almost 5 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/64062
Updated by Sebastian Lechenbauer almost 5 years ago
"As soon as the additional record gets saved along with the real selection, the number of MM records increases by one, which potentially adds another record and so on."
I can confirm this. That is quite problematic, as by repeated saving the MM relations are completely changed - unnoticed by the editor.
Patch set 2 solves the problem for me!
Updated by Gerrit Code Review almost 5 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/64062
Updated by Ephraim Härer almost 5 years ago
Gerrit Code Review wrote:
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/64062
For me this patch worked as expected.
Had also the problem with a MM relation table configured in a TCA field:
'myfield' => [
'exclude' => 1,
'displayCond' => 'mydisplaycondition',
'label' => 'my label',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_foreign_table',
'foreign_table_where' => ' AND tx_foreign_table.deleted=0 ORDER BY tx_foreign_table.field',
'MM' => 'tx_myext_foreign_mm',
'maxitems' => 9,
'size' => 9,
'enableMultiSelectFilterTextfield' => true,
'fieldControl' => [
'editPopup' => [
'disabled' => false,
],
'addRecord' => [
'disabled' => true,
],
'listModule' => [
'disabled' => true,
],
],
'fieldWizard' => [
'localizationStateSelector' => [
'disabled' => true,
],
],
'localizeReferencesAtParentLocalization' => false,
'disableNoMatchingValueElement' => true,
]
],
Updated by Ephraim Härer almost 5 years ago
- Related to Bug #89998: Problem in TCA with type select if MM relation is used added
Updated by Christian Eßl almost 5 years ago
- Priority changed from Should have to Must have
- Target version set to next-patchlevel
Updated by Gerrit Code Review almost 5 years ago
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/64102
Updated by Christian Eßl almost 5 years ago
- Related to Bug #90999: selectMultipleSideBySide adds non selected items added
Updated by Gerrit Code Review almost 5 years ago
Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/64134
Updated by Tobi Kretschmann almost 5 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 0747f03cd0d30d85dfbd72b22a78e70fdf866b48.
Updated by Georg Ringer almost 5 years ago
- Has duplicate Bug #91062: MM select displays not saved items in 9.5.15 added
Updated by Benni Mack almost 5 years ago
- Status changed from Resolved to Closed