Issue Bug Under Review Quiet

#110903sorting_foreign of MM relations is lost when a record is versioned in a workspace

Georg Ringer 10/03/26, 05:38 updated 10/03/26, 05:52

Description

Description

When a record holding the local side of an MM relation is modified in a workspace, the DataHandler creates a workspace version and copies its MM relations. In the copied MM rows, sorting_foreign is set to 0 and only sorting is written. The sorting of the opposite side is lost.

The copy is done via DataHandler::copyRecord_processManyToMany(): the relations are read with the RelationHandler (which includes sorting and sorting_foreign in the item array), but are passed on as a plain uid list. RelationHandler::writeMM() then inserts the new rows with the sorting field of the current side only.

When the version is published, its MM rows replace the live rows, so the wrong sorting ends up in live. On the opposite side, the relation moves to the first position.

How to reproduce

Core functional test fixture EXT:core/Tests/Functional/Fixtures/Extensions/test_mm, data set DataScenarios/ManyToMany/DataSet/ImportDefaultWorkspaces.csv:

  • tx_test_mm.group_mm_1_local (local side, MM_oppositeUsage) <-> tt_content.group_mm_1_foreign (foreign side, MM_opposite_field), MM table group_mm_1_relations_mm
  • Live row: uid_local=28, uid_foreign=297, sorting=0, sorting_foreign=1

Modify tx_test_mm:28 in workspace 1, e.g. change the title. The version (uid 32) gets the row:

_.uid_local _.uid_foreign _.sorting _.sorting_foreign
32 297 1 0

Expected: sorting_foreign=1, as in the live row.

This wrong state is currently pinned in the expectations of the core tests, e.g. DataScenarios/ManyToMany/WorkspacesModify/DataSet/modifyTestMM.csv (32,297,"tt_content",1,0) and WorkspacesPublish/DataSet/modifyTestMM.csv (28,297,"tt_content",1,0 after publishing).

Expected behaviour

Copying the MM relations to a workspace version keeps both sorting and sorting_foreign of the original rows, so the order of the relations on the opposite side does not change when the version is created or published.

Reviews 1

History 12