Review main Merged

71094[BUGFIX] No MM relations when localizing categories

Christian Kuhn CR +2 V +2 Normal +84 −31 updated 09/16/21, 15:14

Commit message

"True" MM relations (those tables that have a "uid_local"
and "uid_foreign" db column and NO TCA) have a "local" and
a "foreign" side. For instance with categories, the category
table is the "local" side, and the referencing table "pages",
"tt_content", or whatever table, is the foreign side.

Without the patch, MM table rows when localizing the local
side of an MM relation is buggy, scenario:

A default language tt_content record references
a default language category. This gives one row in the mm
table. If now the category is localized, a second entry
from the localized category to the default language content
element is added. This is wrong.

The patch fixes this in the DataHandler by setting a
dedicated override for this "local side localization" scenario,
so the RelationHandler omits MM processing in this case. A
functional test is added for non-workspace that exists
for workspace already to verify a new relation can still
be added when creating the local side.

Note this is only half of the picture - MM relation should
still be set and updated when a localized foreign side exists
for the just localized local side. This does not happen
currently and leads to broken MM rows even with the patch. This
scenario however needs a bigger refactoring and further
increased coverage and will be handled with further patches.

Still, this patch is relatively straight forward, increases
test coverage for future patches and already solves various
long standing forge issues.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Oli Bartsch +1
    • Jochen Roth +1
  • Verified V +2 Done
    • Benni Mack +2
    • Oli Bartsch +1
    • Jochen Roth +1
    • core-ci +1 CI

Issues 6

Files 10

Review log 810

  1. Christian Kuhn uploaded patch set 1 09/15/21, 17:59

  2. core-ci voted on patch set 1 V +1 09/15/21, 18:13 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16753

  3. Christian Kuhn updated the commit message in patch set 2 09/15/21, 18:46

  4. core-ci voted on patch set 2 V +1 09/15/21, 19:01 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16758

  5. Jochen Roth voted on patch set 2 V +1 CR +1 09/15/21, 19:57

  6. Oli Bartsch voted on patch set 2 V +1 CR +1 09/15/21, 21:48

  7. Markus Klein commented on patch set 2 09/16/21, 09:17

    Without having dug deeply, a few questions: * Does that mean we only store relation to the default language category from now on? * Isn't that breaking for any extension that relied on the current records? * Isn't this actually a workaround for the fact the the MM relation table for sys_category is actually wrong in the terms of the definition of an MM in TYPO3? The category is actually always the foreign side for any other entity. Correct would be to relate tt_content as local side to a sys_category on the foreign side. Localizing the local side would then make the behaviour correct as the translations would get their relation to the category. Maybe the whole thing is way more complicated than this fix suggests. I cannot judge this so easily. I suspect that this might break things for other MM relations in extensions. (no example at hand currently though)
  8. Christian Kuhn commented on patch set 2 09/16/21, 13:34

    Reply

    > * Does that mean we only store relation to the default language category from now on? No. Of course not! There are further bugs, but in the end, a localized tt_content or page record connection to a localized category should have an mm table entry with exactly these uid's in them. Other relations like inline foreign field and inline csv do the same: They reference the localized records. We did that a couple of version ago already and MM should follow with this strategy. > * Isn't that breaking for any extension that relied on the current records? No. The only change is, as i tried to explain in the commit message: You have a default lang tt_content element, connected to a default lang sys_category record -> 1 mm entry. Good. Then the category is localized, which adds an *additional* mm record from the not-localized tt_content to the just localized category. That's of course broken. See the "Resolved" issues, they explain this with different wordings, too. There are further broken scenarios when for instance connecting a localized tt_content to a already localized category, those are broken, too, but they'll be further patches and they may need interface adaptions to be more visible, too. For now, this patch simply takes care that no surplus mm row is written when localizing the local side of a relation, since that leads to various issues for instance in the frontend where categories then tend to be rendered twice. The tests (should?!) verify the patch impacts exactly only this scenario, that's also why the code change is within the localize() method of DH and not within RelationHandler where i tried it first and recognized that creates too much not wanted impact. > * Isn't this actually a workaround for the fact the the MM relation table for sys_category is actually wrong in the terms of the definition of an MM in TYPO3? The category is actually always the foreign side for any other entity. Correct would be to relate tt_content as local side to a sys_category on the foreign side. Localizing the local side would then make the behaviour correct as the translations would get their relation to the category. well. sys_category is uid_local in mm, that's why it's 'local' side from code point of view. i also think that's kinda ok'ish, since many foreign tables link to the one local category table. from this point, sys_category "local" is "the one" and foreign are "the others". it's kinda core internal thinking and does not match that too much for an editor, though. > I suspect that this might break things for other MM relations in extensions. (no example at hand currently though) Don't know how this is breaking.
  9. Benni Mack voted on patch set 2 V +2 CR +2 09/16/21, 15:14

  10. Benni Mack merged patch set 3 09/16/21, 15:14