Skip to content

Bug: tceDeleteCommands Overwritten When Deleting Multiple Child Tables #391

@crookoo

Description

@crookoo

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():

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_import 7.3.0 (but in current version still in place)
  • Occurs when using multiple children configurations per parent record

Steps to Reproduce:

  1. Import a record with two child configurations: e.g., financing and leasing.
  2. On the next import, remove the financing data but leave leasing.
  3. Observe: financing entries remain in DB and are not deleted.
  4. Only the leasing delete commands are sent to TCEmain.

Additional Context:

This bug is subtle and not immediately visible unless you debug the $tceDeleteCommands structure during import.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions