diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index 3a669f405b5973d354f685ad72aaea81404cbdd2..ecb3f7476d923199c5467630cec7ec102cdf7085 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -6076,6 +6076,7 @@ class DataHandler // Processes the remap stack: if (is_array($this->remapStack)) { $remapFlexForms = []; + $hookPayload = []; foreach ($this->remapStack as $remapAction) { // If no position index for the arguments was set, skip this remap action: @@ -6151,18 +6152,18 @@ class DataHandler $remapFlexForms[$flexFormId][$flexFormPath] = $newValue; } - // Process waiting Hook: processDatamap_afterDatabaseOperations: + + // Collect elements that shall trigger processDatamap_afterDatabaseOperations if (isset($this->remapStackRecords[$table][$rawId]['processDatamap_afterDatabaseOperations'])) { $hookArgs = $this->remapStackRecords[$table][$rawId]['processDatamap_afterDatabaseOperations']; - // Update field with remapped data: - $hookArgs['fieldArray'][$field] = $newValue; - // Process waiting hook objects: - $hookObjectsArr = $hookArgs['hookObjectsArr']; - foreach ($hookObjectsArr as $hookObj) { - if (method_exists($hookObj, 'processDatamap_afterDatabaseOperations')) { - $hookObj->processDatamap_afterDatabaseOperations($hookArgs['status'], $table, $rawId, $hookArgs['fieldArray'], $this); - } + if (!isset($hookPayload[$table][$rawId])) { + $hookPayload[$table][$rawId] = [ + 'status' => $hookArgs['status'], + 'fieldArray' => $hookArgs['fieldArray'], + 'hookObjects' => $hookArgs['hookObjectsArr'], + ]; } + $hookPayload[$table][$rawId]['fieldArray'][$field] = $newValue; } } @@ -6171,6 +6172,23 @@ class DataHandler $this->updateFlexFormData($flexFormId, $modifications); } } + + foreach ($hookPayload as $tableName => $rawIdPayload) { + foreach ($rawIdPayload as $rawId => $payload) { + foreach ($payload['hookObjects'] as $hookObject) { + if (!method_exists($hookObject, 'processDatamap_afterDatabaseOperations')) { + continue; + } + $hookObject->processDatamap_afterDatabaseOperations( + $payload['status'], + $tableName, + $rawId, + $payload['fieldArray'], + $this + ); + } + } + } } // Processes the remap stack actions: if ($this->remapStackActions) { diff --git a/typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/HookTest.php b/typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/HookTest.php index 6c72ea72ea4995a9abfe3b1687664244b4212721..ee32d0e1464175be2d89f3efc00fa51da4331542 100644 --- a/typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/HookTest.php +++ b/typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/HookTest.php @@ -204,13 +204,6 @@ class HookTest extends AbstractDataHandlerActionTestCase 'fieldArray' => [ 'header' => 'Testing #1', self::FIELD_ContentHotel => 1, - ], - ], - // @todo Fix the double invocation for this tt_content record - [ - 'table' => self::TABLE_Content, - 'fieldArray' => [ - 'header' => 'Testing #1', self::FIELD_Categories => 1, ], ],