Review main Merged

71097[BUGFIX] Avoid dangling MM relations on workspace publish

Christian Kuhn CR +2 V +2 Expert +1033 −158 updated 09/21/21, 09:51

Commit message

When publishing workspace records with connected
"true" MM relations (uid_local / uid_foreign columns
and no TCA for that table), DataHandler triggers bugs:

* It updates uid_local or uid_foreign rows to negative
  uids during the process as intermediate DB state.
* It leaves "dangling" MM rows of the workspace record
  that has been pushed live.

The involved code is relatively well encapsulated,
it only kicks in for this "publish MM relations"
scenario, the impact of this patch is limited to
this area.

The patch rewrites MM workspace publish handling:

* Avoid parking state in a DataHandler class property
  only used in this scenario.
* Avoid moving a list of stateful RelationHandler
  instances around and dynamically calling methods
  on those instances.
* Avoid recursive flex form MM publish handling with
  indirect callback methods that change class state.
* Obsolete a RelationHandler method used only in
  this scenario.
* Reduce number of queries.

The result is a simplified, better encapsulated and well
commented solution. On a testing side, the patch brings
a scenario to verify flex form MM relation handling.
An according styleguide example is pending, too.

This patch allows us to change auto created MM table
definitions to unsigned uid_local and uid_foreign columns,
which is of course the right way to go.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Stefan Bürk +1
    • Benni Mack +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Stefan Bürk +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 2

Files 46

Show 26 more files

Review log 2338

Show 713 earlier messages
  1. Christian Kuhn uploaded patch set 1 09/15/21, 20:20

  2. core-ci voted on patch set 1 V -1 09/15/21, 20:41 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16766

  3. Christian Kuhn commented on patch set 1 CR -1 09/15/21, 21:20

    This reveals that DH workspace publish on MM leaves duplicate MM rows for existing relations, plus there is an issue with negative uid's.
  4. Christian Kuhn uploaded patch set 2 09/18/21, 16:23

  5. core-ci voted on patch set 2 V -1 09/18/21, 16:42 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16909

  6. Christian Kuhn uploaded patch set 3 09/18/21, 23:52

  7. core-ci voted on patch set 3 V -1 09/19/21, 00:11 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16910

  8. Christian Kuhn uploaded patch set 4 09/19/21, 01:11

  9. core-ci voted on patch set 4 V -1 09/19/21, 01:33 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16912

  10. Christian Kuhn uploaded patch set 5 09/19/21, 01:43

  11. core-ci voted on patch set 5 V -1 09/19/21, 01:59 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16913

  12. Christian Kuhn uploaded patch set 6 09/19/21, 11:01

  13. core-ci voted on patch set 6 V -1 09/19/21, 11:19 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16916

  1. Christian Kuhn uploaded patch set 7 09/19/21, 11:19

  2. core-ci voted on patch set 7 V -1 09/19/21, 11:35 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16917

  3. Christian Kuhn uploaded patch set 8 09/20/21, 06:35

  4. core-ci voted on patch set 8 V -1 09/20/21, 06:50 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16924

  5. Christian Kuhn uploaded patch set 9 09/20/21, 07:21

  6. core-ci voted on patch set 9 V +1 09/20/21, 07:38 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16925

  7. Christian Kuhn uploaded patch set 10 09/20/21, 11:44

  8. core-ci voted on patch set 10 V +1 09/20/21, 12:01 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16933

  9. Christian Kuhn uploaded patch set 11 09/20/21, 13:00

  10. Christian Kuhn uploaded patch set 12 09/20/21, 13:08

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

  12. core-ci voted on patch set 12 V +1 09/20/21, 13:33 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16938

  13. Christian Kuhn commented on patch set 12 09/20/21, 14:43

    stefan will review this.
  14. Stefan Bürk commented on patch set 12 V +1 09/20/21, 18:13

    Thanks for the patch, Christian. Looked through all the parts, and as such working. Only have two small comments, where of the first one I'm not sure if it could maybe be a currenlty untested constellation or if it would be handled on other places. If I'm wrong there, I would vote +1, as the patch is workin as such. Regarding the reference test assertions, not a blocker - but maybe would make more sense ?

    DataHandler.php:5944

    Maybe add a `?? false` here as safety check, as not checked for existing MM key before - for flexform field? Normal TCA field has a prior check. (L5866) isReferenceField() do not check for MM key/array in field config; Would it make sense to add the MM key check of field config into that method ? Would make condition in L5866 also "smaller".

    ActionTest.php:35

    This test is on different tests with the same name, just commenting one: Would it not make more sense to do (and the other places) that assertCleanReferenceIndex is not disabled ?? ``` self::assertTrue($this->assertCleanReferenceIndex); ``` If it should be disabled this test is absolutly useless otherwise, or ?
  15. Christian Kuhn commented on patch set 12 09/20/21, 18:46

    DataHandler.php:5944 Reply

    > Maybe add a `?? false` here as safety check, as not checked for existing MM key before - for flexform field? Normal TCA field has a prior check. (L5866) empty() never throws notices or warnings on accessing non-existing arrays. > isReferenceField() do not check for MM key/array in field config; Would it make sense to add the MM key check of field config into that method ? isReferenceField() is used in different context, too, we shouldn't change that right now.

    ActionTest.php:35 Reply

    that property will fall as soon as mm handling correctly handles refindex.
  16. Christian Kuhn uploaded patch set 13 09/20/21, 18:46

  17. core-ci voted on patch set 13 V +1 09/20/21, 19:00 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16948

  18. Christian Kuhn rebased onto patch set 14 09/20/21, 19:09

  19. core-ci voted on patch set 14 V +1 09/20/21, 19:25 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16949

  20. Christian Kuhn uploaded patch set 15 09/20/21, 20:11

  21. core-ci voted on patch set 15 V +1 09/20/21, 20:25 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/16953

  22. Stefan Bürk voted on patch set 15 V +1 CR +1 09/20/21, 21:43

  23. Benni Mack voted on patch set 15 V +1 CR +1 09/21/21, 09:16

  24. Christian Kuhn voted on patch set 15 V +2 CR +2 09/21/21, 09:51

  25. Christian Kuhn merged patch set 16 09/21/21, 09:51