Project

General

Profile

Actions

Bug #95400

open

Workspace broken mm relation

Added by Juraj Sulek over 2 years ago. Updated about 2 years ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
Workspaces
Target version:
-
Start date:
2021-09-29
Due date:
% Done:

0%

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

Description

There is a bug, which is also present in the 11 version. This problem occurs if there is mm table and both, foreign and local records have workspace version.

Let's say we have folowing tables

products (with record uid:1)
color (width records uid:1 and uid:2)
products_color_mm (with
1|1
1|2
)

Now if we switch to Workspace and create a new color (it will have uid:3)
If we now edit the product, make some changes and save it, a new workspace version will be created uid:2

The products_color_mm contains now
1|1
1|2
2(WS version of uid:1)|1
2(WS version of uid:1)|3(WS version of uid:1)

here the 2|3 is the problem, because:
1) In the BE (e.g. in side by side selectbox) in the itemArray of possible colors (right selectbox), all colors have non-workspace UID's. But in the itemArray of already selected, the values from MM are taken - in this case 1(non-WS) and 3 (WS). So in the BE it will always look like if 2|3 is not selected.

2) If we publish the workspace. The foreign field in mm table is not updated and it is still 3, even if 3 doesn't exist anymore because it was published and has now again uid 1. And so the product looses this relation.

The only solution i have found, is to save the foreign key always with non-ws uid. It works in our project, but maybe this solution will not work if there is a bidirectional relation.

Here is a fix i have found:
typo3/sysext/core/Classes/DataHandling/DataHandler.php
function checkValue_group_select_processDBdata
coder
// convert submitted items to use version ids instead of live ids
// (only required for MM relations in a workspace context)
$dbAnalysis->convertItemArray();

if i delete the $dbAnalysis->convertItemArray(); here everythings works fine.

I have also tried to modify the core so that both itemArrays have WS-id's if the WS version of the record exists. This has fixed the problem for BE, but there is still the problem (2) where after workspace publication the mm relation is broken because the foreign key is not updated.


Files

test.zip (23.1 KB) test.zip Juraj Sulek, 2021-12-13 09:34
sr.mov (6.69 MB) sr.mov Juraj Sulek, 2021-12-13 09:36
Actions

Also available in: Atom PDF