Issue Feature Needs Feedback Stale

#110542Add enableHistory flag to DataHandler

Pascal Galle 08/27/26, 13:32 updated 09/17/26, 20:55

Description

Hello,

in one of my projects we import a large amount of records into TYPO3 and dataHandler is being used to store this data into the database. We found, that it started to flood the sys_history table.
For us the easiest way would be to simply set a flag $enableHistory, the same like with $enableLogging, that allows us to skip the sys_history writes on import.

For version 13 I already created a patch locally, which works for our needs:

--- a/Classes/DataHandling/DataHandler.php
+++ b/Classes/DataHandling/DataHandler.php
@@ -125,6 +125,13 @@
     public bool $enableLogging = true;

     /**
+     * If TRUE, changes are recorded to sys_history for undo/history purposes.
+     * Set to FALSE for high-volume programmatic imports where a full undo
+     * trail is not needed and would otherwise flood sys_history.
+     */
+    public bool $enableHistory = true;
+
+    /**
      * If TRUE, the datamap array is reversed in the order, which is a nice thing if you're creating a whole new
      * bunch of records.
      */
@@ -7865,11 +7872,35 @@
     protected function getRecordHistoryStore(): RecordHistoryStore
     {
+        if (!$this->enableHistory) {
+            return new class extends RecordHistoryStore {
+                public function addRecord(string $table, int $uid, array $payload, ?CorrelationId $correlationId = null): string
+                {
+                    return '';
+                }
+                public function modifyRecord(string $table, int $uid, array $payload, ?CorrelationId $correlationId = null): string
+                {
+                    return '';
+                }
+                public function deleteRecord(string $table, int $uid, ?CorrelationId $correlationId = null): string
+                {
+                    return '';
+                }
+                public function undeleteRecord(string $table, int $uid, ?CorrelationId $correlationId = null): string
+                {
+                    return '';
+                }
+                public function moveRecord(string $table, int $uid, array $payload, ?CorrelationId $correlationId = null): string
+                {
+                    return '';
+                }
+            };
+        }
         return GeneralUtility::makeInstance(
             RecordHistoryStore::class,
             RecordHistoryStore::USER_BACKEND,
             (int)$this->BE_USER->user['uid'],
             (int)$this->BE_USER->getOriginalUserIdWhenInSwitchUserMode(),
             $GLOBALS['EXEC_TIME'],
             $this->BE_USER->workspace
         );
     }

Might that be something we can include into the core of v13 upwards? If yes I can try to create a change request for v13, v14 and main

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch

Commit message
[FEATURE] Add enableHistory flag to DataHandler Resolves: #110542 Releases: main

History 3

  1. Benni Mack commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2026-09-02T15:44:47+00:00" > 09/02/26, 15:44 </span>

    Well, the reason for not having such an option in the past is to find out when a record was created by whom.

    If we don’t have the information, and editor starts to manage this imported content, we only know when it was changed (in the history) but not when it was imported and by whom. I think we could offer a event/hook or something like to disable it, but not as an official option.

  2. Pascal Galle commented <span data-processor="relativetime" data-value="2026-09-02T18:20:54+00:00" > 09/02/26, 18:20 </span>

    Benni Mack wrote in #note-1:
    > Well, the reason for not having such an option in the past is to find out when a record was created by whom.
    >
    > If we don’t have the information, and editor starts to manage this imported content, we only know when it was changed (in the history) but not when it was imported and by whom. I think we could offer a event/hook or something like to disable it, but not as an official option.

    Fair point, maybe another solution would be to batch the history somehow? Not sure how to do that on the top of my head though. Use case, as mentioned, for me is an import that is being done via DataHandler.

  3. Benni Mack commented <span data-processor="relativetime" data-value="2026-09-17T20:55:05+00:00" > 09/17/26, 20:55 </span>

    Pascal Galle wrote in #note-2:

    > Fair point, maybe another solution would be to batch the history somehow? Not sure how to do that on the top of my head though. Use case, as mentioned, for me is an import that is being done via DataHandler.

    I’m actually planning on restructuring DataHandler to become more OOP, with better ways to intercept such things. Stay tuned…