Review main Merged

88193[TASK] Avoid DataHandler->getRecordProperties() in moveRecord()

Christian Kuhn CR +2 V +2 Normal +148 −55 updated 02/21/25, 09:56

Commit message

This is the next patch to reduce usages of getRecordProperties()
in DataHandler. It takes care of moveRecord(). The change is
particularly finicky since the result of getRecordProperties()
is fed to hooks in this case. With the workspace hook being a
main hook consumer, we need to ensure backwards compatibility for
handing over the hook information.

moveRecord() is the entry method to move records. The code is
a convoluted mess that is very hard to track since there is no
proper point that establishes a baseline of known facts. Move,
especially within workspaces, is rather complex since the entry
method does not even know if the given uid points to a workspace
record or a live record when the user is in workspaces. Both can
happen. Additionally, the BackendUtility methods tend to mix up
workspace-and-live state by for instance treating "workspace new"
records as "live record", and getRecordProperties() happily follows
to multiply brainmelt. Last, move is additionally complex since
for instance a "workspace changed" record has to be turned into
a "workspace moved" record and "workspace deleted" needs special
treatment as well.

The patch is a careful refactoring of the entry method:

* Create a clean situation of known facts at the start: We end up
  with either $liveRecord, or $workspaceRecord, or both. The code
  looks lengthy, but is well documented. The number of DB calls is
  reduced to a minimum. We will further facilitate this state with
  refactoring of workspace hook and worker method moveRecord_raw(),
  which currently do all the record fetching and preparation again.
  We also add some todos documenting broken and unhandled details.

* With the facts being established, we simplify the access checks
  to a relatively straight list with logging and early returns.
  Note this area is still expensive since most of the check methods
  directly or indirectly call recordInfoWithPermissionCheck(), which
  of course fetches the record in question from DB again. We'll have
  to work on these methods in detail with other patches.

* Last, we create a backwards-compatible array of the two variables
  $propArr and $moveRec that does not rely on getRecordProperties()
  anymore, using the established record state variables. This area
  is ugly, but we need good b/w compat here since - currently - the
  workspace hook highly depends on it. As proof, the workspaces
  DataHandler functional tests found all incarnations of "broken"
  when crafting the patch, I'm rather confident this change should
  not break existing other hook consumers.

With this in place, we can take a closer look at the workspace hook
and at moveRecord_raw(), which will be changed to receive the record
state from moveRecord() instead of doing all the record preparation
again.

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 3

Review log 4781

Show 2856 earlier messages
  1. Christian Kuhn uploaded patch set 1 02/12/25, 11:47

  2. core-ci voted on patch set 1 V +1 02/12/25, 11:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74038

  3. Christian Kuhn uploaded patch set 2 V +1 02/12/25, 11:58

  4. core-ci voted on patch set 2 V +1 02/12/25, 12:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74039

  5. Christian Kuhn uploaded patch set 3 V +1 02/12/25, 14:51

  6. core-ci voted on patch set 3 V +1 02/12/25, 14:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74043

  7. Christian Kuhn uploaded patch set 4 V +1 02/12/25, 16:23

  8. core-ci voted on patch set 4 V +1 02/12/25, 16:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74049

  9. Christian Kuhn uploaded patch set 5 V +1 02/12/25, 16:40

  10. Christian Kuhn uploaded patch set 6 02/12/25, 16:43

  11. core-ci voted on patch set 5 V -1 02/12/25, 16:58 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74051

  12. core-ci voted on patch set 6 V -1 02/12/25, 16:59 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74052

  13. Christian Kuhn uploaded patch set 7 V -1 02/12/25, 16:59

  14. Christian Kuhn uploaded patch set 8 02/12/25, 17:08

  15. core-ci voted on patch set 7 V -1 02/12/25, 17:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74057

  16. Christian Kuhn uploaded patch set 9 02/12/25, 17:16

  17. core-ci voted on patch set 8 V -1 02/12/25, 17:18 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74058

  18. core-ci voted on patch set 9 V +1 02/12/25, 17:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74059

  19. Christian Kuhn uploaded patch set 10 V +1 02/12/25, 18:54

  20. core-ci voted on patch set 10 V -1 02/12/25, 19:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74064

  21. Christian Kuhn uploaded patch set 11 V -1 02/12/25, 19:13

  22. Christian Kuhn uploaded patch set 12 02/12/25, 19:18

  23. core-ci voted on patch set 11 V +1 02/12/25, 19:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74065

  24. core-ci voted on patch set 12 V -1 02/12/25, 19:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74066

  25. Christian Kuhn uploaded patch set 13 V -1 02/12/25, 19:30

  26. core-ci voted on patch set 13 V +1 02/12/25, 19:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74067

  27. Christian Kuhn uploaded patch set 14 V +1 02/12/25, 19:46

  28. Christian Kuhn uploaded patch set 15 02/12/25, 19:47

  29. core-ci voted on patch set 14 V -1 02/12/25, 19:59 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74068

  30. core-ci voted on patch set 15 V -1 02/12/25, 19:59 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74069

  31. Christian Kuhn uploaded patch set 16 V -1 02/12/25, 22:11

  32. Christian Kuhn uploaded patch set 17 02/12/25, 22:13

  33. core-ci voted on patch set 16 V +1 02/12/25, 22:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74070

  34. core-ci voted on patch set 17 V +1 02/12/25, 22:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74071

  35. Christian Kuhn uploaded patch set 18 V +1 02/12/25, 23:04

  36. core-ci voted on patch set 18 V +1 02/12/25, 23:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74072

  37. Christian Kuhn uploaded patch set 19 V +1 02/12/25, 23:24

  38. core-ci voted on patch set 19 V +1 02/12/25, 23:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74073

  39. Christian Kuhn uploaded patch set 20 V +1 02/12/25, 23:33

  40. Christian Kuhn uploaded patch set 21 02/12/25, 23:47

  41. core-ci voted on patch set 21 V +1 02/12/25, 23:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74075

  42. core-ci voted on patch set 20 V +1 02/13/25, 01:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74074

  43. Christian Kuhn uploaded patch set 22 V +1 02/13/25, 22:18

  44. core-ci voted on patch set 22 V +1 02/13/25, 22:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74123

  45. Christian Kuhn rebased onto patch set 23 V +1 02/19/25, 17:47

  46. core-ci voted on patch set 23 V +1 02/19/25, 17:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74406

  47. Christian Kuhn uploaded patch set 24 V +1 02/19/25, 18:53

  48. Christian Kuhn uploaded patch set 25 02/19/25, 18:54

  49. core-ci voted on patch set 24 V -1 02/19/25, 19:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74407

  50. core-ci voted on patch set 25 V -1 02/19/25, 19:06 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74408

  51. Christian Kuhn uploaded patch set 26 V -1 02/19/25, 19:29

  52. core-ci voted on patch set 26 V -1 02/19/25, 19:39 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74409

  53. Christian Kuhn uploaded patch set 27 V -1 02/19/25, 19:52

  54. core-ci voted on patch set 27 V -1 02/19/25, 20:02 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74410

  55. Christian Kuhn uploaded patch set 28 V -1 02/20/25, 09:18

  56. core-ci voted on patch set 28 V -1 02/20/25, 09:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74454

  1. Christian Kuhn uploaded patch set 29 V -1 02/20/25, 10:00

  2. core-ci voted on patch set 29 V +1 02/20/25, 10:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74456

  3. Christian Kuhn updated the commit message in patch set 30 V +1 02/20/25, 10:53

  4. core-ci voted on patch set 30 V +1 02/20/25, 10:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74458

  5. Benni Mack updated the commit message in patch set 31 V +1 02/20/25, 11:31

  6. Christian Kuhn uploaded patch set 32 02/20/25, 11:35

  7. core-ci voted on patch set 31 V +1 02/20/25, 11:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74462

  8. core-ci voted on patch set 32 V +1 02/20/25, 11:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74464

  9. Christian Kuhn commented on patch set 32 02/20/25, 12:14

    DataHandler.php:4442

    comment dupe.
  10. Christian Kuhn commented on patch set 32 02/20/25, 12:15

    DataHandler.php:4448

    Page is resorted within same parent but user does not have update permissions.
  11. Benni Mack uploaded patch set 33 V +1 02/20/25, 15:01

  12. Benni Mack voted on patch set 33 CR +1 V +1 02/20/25, 15:01

  13. Stefan Bürk commented on patch set 33 CR -1 02/20/25, 15:05

    On it ..
  14. core-ci voted on patch set 33 V +1 02/20/25, 15:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74467

  15. Stefan Bürk uploaded patch set 34 CR +1 V +1 02/20/25, 15:41

  16. Stefan Bürk commented on patch set 34 02/20/25, 15:41

    Reply

    Done

    DataHandler.php:4442 Reply

    Done

    DataHandler.php:4448 Reply

    Done
  17. core-ci voted on patch set 34 V +1 02/20/25, 15:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74470

  18. Stefan Bürk voted on patch set 34 CR +1 V +1 02/20/25, 15:55

  19. Benni Mack voted on patch set 34 CR +1 V +1 02/20/25, 16:18

  20. Andreas Kienast commented on patch set 34 02/20/25, 16:30

    DataHandler.php:4353

    Potential caveat: an extension may provide a table that had workspace fields in the past which have been removed meanwhile from TCA without running the database analyzer and removing the fields. How do we deal with this? Ignore, because DB state isn't clean?
  21. Benni Mack commented on patch set 34 02/20/25, 16:47

    DataHandler.php:4353 Reply

    This would be a problem in roughly 250 places...
  22. Christian Kuhn commented on patch set 34 02/20/25, 17:05

    DataHandler.php:4353 Reply

    i docomuneted this scenario in dbdoctor, and it is basically the same with core: core can never know about "previous TCA state". cite from dbdoctor: " dbdoctor always works on the current TCA state. It never knows if some TCA table has been defined "soft-delete-aware" before, and if this has been changed later. When you push records live by removing the "deleted" column, by removing the "workspaces" extension, workspaces related columns, or timing related fields, this can end up with non-repairable state dbdoctor will not be able to fix. Instead, it will tend to find additional database relations that are broken, and will suggest changes that make the situation worse than before. Also, dbdoctor never looks at potentially existing zzz_deleted columns - those do not exist from dbdoctor point of view since they depend on some "before" TCA state that can not be reconstructed again. State created from scenarios like the above ones are not repairable and need manual reconstruction. Good luck. " In addition to that, DH basically expects "most" DB structure to be in sync with TCA - especially new fields. We may catch the one or the other DB exception, but in general, DH (at least currently) expects DB column state is clean.
  23. Christian Kuhn commented on patch set 34 02/20/25, 17:11

    DataHandler.php:4353 Reply

    This (sane) limitation is one reason that for instance upgrade wizards mumble when 'new columns' are missing in DB: DH will explode in your hands when DB table/columnn state is not decent. We *may* be able to mitigate this, but that task is definately not scope of this patch, neither it should be.
  24. Christian Kuhn voted on patch set 34 CR +2 V +2 02/21/25, 09:55

  25. Christian Kuhn merged patch set 35 02/21/25, 09:56