Review 13.4 Merged

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

Christian Kuhn CR +2 V +2 Normal +150 −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
  • Verified V +2 Done
    • Christian Kuhn +2
    • core-ci +1 CI

Issues 2

Files 3

Review log 34

  1. Christian Kuhn uploaded patch set 1 02/21/25, 09:38

  2. core-ci voted on patch set 1 V +1 02/21/25, 09:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74494

  3. Christian Kuhn voted on patch set 1 CR +2 V +2 02/21/25, 09:56

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