-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Description:
When importing records with multiple child relations (e.g., financing, leasing), the deletion commands for child records are not correctly accumulated. Only the last child table’s entries are retained in $tceDeleteCommands, because the variable is overwritten inside the loop.
Current Behavior:
In Cobweb\ExternalImport\Step\StoreDataStep::run():
external_import/Classes/Step/StoreDataStep.php
Lines 407 to 417 in ce60fa7
| foreach ($this->childRecordsToDelete as $childTable => $childList) { | |
| $tceDeleteCommands = [ | |
| $childTable => [], | |
| ]; | |
| foreach ($childList as $child) { | |
| $tceDeleteCommands[$childTable][$child] = [ | |
| 'delete' => 1, | |
| ]; | |
| $deletes++; | |
| } | |
| } |
This reinitializes $tceDeleteCommands in every iteration, discarding previously collected delete commands.
Expected Behavior:
Delete commands for all child tables should be collected and merged into $tceDeleteCommands.
Proposed Fix:
Replace:
$tceDeleteCommands = [
$childTable => [],
];With:
if (!isset($tceDeleteCommands[$childTable])) {
$tceDeleteCommands[$childTable] = [];
}This ensures all child table deletions are accumulated properly.
Impact:
- Child records of earlier child tables (e.g.,
tx_cartvehicles_domain_model_product_financing) are not deleted when later ones (e.g.,leasing) are processed. - Leads to stale or orphaned data in the database.
- Issue only occurs when multiple child tables are involved in a single import.
Environment:
- TYPO3 v11.5.41
external_import7.3.0 (but in current version still in place)- Occurs when using multiple
childrenconfigurations per parent record
Steps to Reproduce:
- Import a record with two child configurations: e.g.,
financingandleasing. - On the next import, remove the
financingdata but leaveleasing. - Observe:
financingentries remain in DB and are not deleted. - Only the
leasingdelete commands are sent to TCEmain.
Additional Context:
This bug is subtle and not immediately visible unless you debug the $tceDeleteCommands structure during import.