Review 13.4 Merged

88150[TASK] Improve DataHandler logging part 1

Christian Kuhn CR +2 V +2 Normal +117 −113 updated 02/10/25, 20:18

Commit message

The DataHandler suffers from a dusty logging strategy: It is slow
by triggering an insane number of DB queries just to prepare log
data, the messages are often not good or lack important data, the
logged pid an event happened on is often determined wrongly. While
various patches over the years adapted certain details, the main
strategy has never been truly reviewed.

Codewise, there are especially the two evil logging related helper
methods: `getRecordProperties()` and `getRecordPropertiesFromRow()`.
In combination, they trigger at least two select(*) queries, and
three with workspaces. This quickly multiplies to significant
query counts when larger structures like pages with many records
or records with many children are changed: Delete a page with some
page translations, having a series of content elements with images
and you are not on a happy path from the logging system alone.

The following decisions have been taken:
* We stop logging "record title" in log messages, but rely on
  "table:uid" instead: Determining the record title in a low level
  structure like the DataHandler can create siginifant additional
  overhead depending on TCA configuration. Also, in many situations,
  and especially with casual content elements, the record title often
  ends up empty, leading to [No title] logs. Lastly, this information
  is not very helpful in a logging stream where the record title can
  constantly change: Looking up log rows based on this information
  is doomed as soon as an editor changes the title. The only thing
  that never changes during a record CRUD lifetime is the table:uid
  combination.
* A subtle change with logging "event pid" - the page uid a change
  happened on: We will now always log using the 'pid' field of
  records. The pid field is a reliable source of truth since it almost
  always points to the uid of a default language live page record.
  When a page record is changed, we now set 'pid' within logging to
  the uid of the "parent" page, instead of the page records own "uid".
  We will later adapt the log module to reflect this. For now, this
  change should be fine since pid determination often went wrong,
  leading to many log records being set to pid 0.

This patch gets rid of all `getRecordPropertiesFromRow()` usages:
The method is not only used indirectly from `getRecordProperties()`,
but also directly in some other places. Especially `updateDB()` is
problematic here. To suppress the call, we change its signature
to receive the $recordPid explicitly. Many consumers have the
current record at hand already and can submit it, and two consumers
are changed to get the record. These two cases can probably be
avoided later with additional refactorings.

The patch also cleans up a practically duplicate log row in
workspaces DataHandlerHook, plus some further cleanups along
the way.

Method `getRecordPropertiesFromRow()` is dissolved and inlined
to `getRecordProperties()` for now, its last consumer.

The v13 backport of the patch will keep the method and will
make the signature change on `updateDB()` optional.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
  • Verified V +2 Done
    • Christian Kuhn +2
    • core-ci +1 CI

Issues 1

Files 3

Review log 34

  1. Christian Kuhn uploaded patch set 1 02/10/25, 20:05

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

  3. Christian Kuhn voted on patch set 1 CR +2 V +2 02/10/25, 20:18

  4. Christian Kuhn merged patch set 2 02/10/25, 20:18