#110542Add enableHistory flag to DataHandler
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