Skip to content

Commit

Permalink
[BUGFIX] Avoid useless database updates in DataHandler
Browse files Browse the repository at this point in the history
DataHandler has an internal check that compares the sent payload with
the state of the affected database record and removes fields from the
payload that didn't change.

Everytime a database record is updated, DataHandler resets the internal
stage to "0" to start a new editing workflow, if the affected database
table supports workspaces. This handling is unfortunately executed
*after* the payload comparison is done, leading to a payload that
always instructs to update the field `t3ver_stage`, even if the change
is not necessary, leading to superfluous database updates. This has a
massive negative performance impact in simple shared hosting
environments, especially with tt_content records that have many
file references attached.

The payload comparison is now executed after setting `t3ver_stage` to
filter out superfluous updates.

Resolves: #100035
Releases: main, 11.5
Change-Id: Ie0e29f7efe8d6289849bf117fbc852108fac1dd7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77987
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
  • Loading branch information
andreaskienast committed Mar 1, 2023
1 parent 8d6c058 commit 372cef1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions typo3/sysext/core/Classes/DataHandling/DataHandler.php
Expand Up @@ -1076,17 +1076,18 @@ public function process_datamap()
if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id'] ?? false) {
$fieldArray[$GLOBALS['TCA'][$table]['ctrl']['cruser_id']] = $this->userid;
}
} elseif ($this->checkSimilar) {
}
// Set stage to "Editing" to make sure we restart the workflow
if (BackendUtility::isTableWorkspaceEnabled($table)) {
$fieldArray['t3ver_stage'] = 0;
}
if ($status !== 'new' && $this->checkSimilar) {
// Removing fields which are equal to the current value:
$fieldArray = $this->compareFieldArrayWithCurrentAndUnset($table, $id, $fieldArray);
}
if (($GLOBALS['TCA'][$table]['ctrl']['tstamp'] ?? false) && !empty($fieldArray)) {
$fieldArray[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
}
// Set stage to "Editing" to make sure we restart the workflow
if (BackendUtility::isTableWorkspaceEnabled($table)) {
$fieldArray['t3ver_stage'] = 0;
}
// Hook: processDatamap_postProcessFieldArray
foreach ($hookObjectsArr as $hookObj) {
if (method_exists($hookObj, 'processDatamap_postProcessFieldArray')) {
Expand Down

0 comments on commit 372cef1

Please sign in to comment.