Review main Merged

72250[BUGFIX] Better sys_refindex with workspace mm

Christian Kuhn CR +2 V +2 Hard +564 −145 updated 11/24/21, 22:13

Commit message

This fixes issues regarding sys_refindex handling when dealing
with workspace mm relations. Various DataHandler tests run with
disabled refindex check after performing mm related operations.
All those are enabled now, so all known issues in this area
are fixed.

The patch touches various areas in DataHandler, ReferenceIndex
and RelationHandler to achieve this.

The key changes are triggered by a database scenario that is
unique for mm relations. Usually, when creating a workspace record
or overlay, child record overlays (for instance inline children)
are also created in this workspace.

For mm records, this can be different: When the local or foreign
side of a record is created in a workspace, it does not necessarily
mean that a connected opposite side is also created as workspace
overlay.

This would otherwise create the need for a recursive operation that
would basically end up with "everything" being created as workspace
overlay. However, mm table entries are created for these relations,
leading to a situation that a workspace record can point to a
non-workspace record through the mm table.

Reference index entries for mm table connections are always handled
from the 'local' side. For instance, with categories, 'sys_category'
table is the local side, with 'pages', 'tt_content' and others
being the foreign side. If now one of the records on the foreign
side gets a workspace overlay record, sys_refindex rows of all
connected records of the affected local side need to be created.
This can lead to the funny situation that we end up with refindex
rows that point from a non-workspace to a non-workspace record,
but have a non-0 workspace entry. Those additional rows are needed
to have "the full set" and proper sorting when looking at refindex
of such a relation from the local side.

The patch basically handles especially these 'foreign side has
a workspace overlay' scenarios, plus the side effects that
have to be taken care of when discarding and publishing these
records.

Additionally, a couple of side effects are tackled: First, the
ReferenceIndex->updateIndex() - that's the main logic when
running cli referenceindex:update command - is tuned to drop
reference index entries related to meanwhile deleted workspaces.
This is covered with additional tests and is done now since
the code needs to iterate over existing workspaces for local-side
mm records that may have workspace overlays on the foreign side.
So most of the code had to be created now anyways.

RelationHandler->readMM() receives a fix for a long standing bug
(Issue #83582, introduced by #57169), to no longer show workspace
relations in live when looking at local-side records, for instance
when looking at category items in live when one of the connected
items has a workspace overlay.

Next to lots of comments explaining details in place and
referencing the test cases that nail specific scenarios, a
couple of @todo's are added to point out things we may
want to tackle in the future.

All in all, the patch resolves a series of issues that will
especially lead to 'categories' being much more reliable in
workspaces.

Review

  • Code review CR +2

    Imported before Forger kept the single votes, the next import adds them.

  • Verified V +2

    Imported before Forger kept the single votes, the next import adds them.

Issues 3

Files 40

Show 20 more files