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 #1

Updated by Christian Kuhn over 2 years ago

  • Status changed from New to Needs Feedback

Hey.

Thanks for your report. I played around with your scenario, but I'm unable to reproduce. Maybe you could help me out. I'm using 'category->tt_content', since that's a scenario delivered by core already.

a)
  • live: create a category, uid 1
  • live: create two content elements, connect them to cat 1, uid 1,2
  • workspace: create a third content element, uid 3
  • workspace: edit category 1, change title, safe, uid 2

-> (categories uids left)
1|1
1|2
2|2
2|1

-> looks good to me.

b) the other way around
  • live: create two categories, uid 1,2
  • live: create content element, connect to cat 1, uid 1
  • workspace: create a third category, uid 3
  • workspace: edit content element 1, change title, safe, uid 2

-> (category uids left)
1|1
2|1
2|2
1|2

-> looks good to me.

I tried with main and not v11, but that shouldn't make much of a difference in this case. If this is still reproducible for you, I'd be interested in more details, maybe even a as-simple-as-possible example extension to sort this out.

Updated by Juraj Sulek over 2 years ago

I have testet it now on Typo3 11. There is still this bug in BE but FE works fine with the WS is in the mm Table. On Typo3 10 also the FE donesn't work and i had to create a hook which overwrides the ws IDs' in the mm table after modification in BE - unfortunately in 11 this will not work anymore.
Just to be sure have i createt a new Typo3 11 with composer, without templates etc. Then i have installed extension_builder and createt the extension from scratch just with the necessary fields. I have attached also a video where you can see what is the problem.

Actions #3

Updated by Lidia Demin about 2 years ago

Not sure if this is related, but I have an issue if both a sys_category and a linked record are new items in a workspace on TYPO3 10.4.22.

Being in a workspace I created a new category and a new product. In the product's editing interface I see the new category and can select it, but when I save the product, the category is not linked anymore, although the entries exist in the database:

sys_category:
uid t3ver_oid t3ver_wsid t3ver_state
570 569 1 -1
569 0 1 1
product:
uid t3ver_oid t3ver_wsid t3ver_state
1541 1540 1 -1
1540 0 1 1
sys_category_record_mm:
uid_local uid_foreign tablenames
570 1541 product

Maybe this is easier to reproduce and helps you with investigation.

Actions #4

Updated by Lidia Demin about 2 years ago

My issue seems to be fixed in version 11. Thanks Christian Kuhn for helping me on Slack with this ;)

Actions

Also available in: Atom PDF