#95541Strange behavior of DataHandler regarding hard- and flag-delete with enableCascadingDelete
Description
We stumbled over a strange behavior deleting records in the Backend with cascade-delete of child-records, where it’s not sure if this is expected how it works right now. Wording first:
- flag-delete: TCA [ctrl][delete] is set to ‘deleted’, so the record will be marked as deleted
- hard-delete: TCA [ctrl][delete] is NOT set, so the record will be really deleted
Lets say we have a chain of 1->N relations like: “A has many Bs and each B has many Cs”. If A is deleted, we want also all related Bs and their Cs to be deleted, that’s why the TCA fields are configured like this (shorted):
// table A:
'b_rels' => [
'config' => [
'type' => 'inline',
'foreign_table' => 'b',
'foreign_field' => 'a_uid',
'behaviour' => [
'enableCascadingDelete' => TRUE,
],
],
],
// table B:
'c_rels' => [
'config' => [
'type' => 'inline',
'foreign_table' => 'c',
'foreign_field' => 'b_uid',
'behaviour' => [
'enableCascadingDelete' => TRUE,
],
],
],
Case 1: For all tables the flag-delete is configured. In this case, deleting record A works fine, all its child-records B and C will also have the flag ‘deleted’ set to 1. This is like expected, fine!
Case 2: For all tables the hard-delete is configured. In this case, the record A is really deleted, but B and C remain untouched.
*But we expect that A, Bs and Cs are ALL really deleted!*
Lets try the following:
If we add [ctrl][delete]=‘deleted’ to table A, then the A.deleted is set to 1 and Bs are really deleted (Cs remain untouched).
If we add [ctrl][delete]=‘deleted’ also to table B, then the A.deleted and B.deleted is set to 1, and Cs are really deleted.
Is this expected behavior?
If so, how to hard-delete such a chain of records? If only A is hard-deleted and the related Bs and Cs remaining but having no parent anymore (like it is right now), this will mess up the database over time.
TYPO3 v10.4.21
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Related issues 1
History 3
-
Johannes Nielsen commented <span data-processor="relativetime" data-value="2024-06-04T14:07:32+00:00" > 06/04/24, 14:07 </span>
-
Benni Mack changed Related to #79014 <span data-processor="relativetime" data-value="2026-11-09T08:21:50+00:00" > 11/09/26, 08:21 </span>
-
Benni Mack commented and changed status
NewClosed <span data-processor="relativetime" data-value="2026-11-09T08:22:07+00:00" > 11/09/26, 08:22 </span>Closing as duplicate of #79014. Since that change (main / 13.4, merged 2025-05), when a record is hard-deleted (no ctrl.delete, or forced via recycler), its inline children with enableCascadingDelete are hard-deleted recursively as well, so an A → B → C chain is removed completely. This is covered by the functional tests in DataScenarios/IrreForeignField (deleteParentContentWithoutSoftDelete). The fix has not been backported to 12.4 or older.
This issue is still present in 12.4.15. Interestingly enough, the DataHandler seems to delete child records only in case of “soft delete” (this is the line of code that does so: https://github.com/TYPO3/typo3/blob/main/typo3/sysext/core/Classes/DataHandling/DataHandler.php#L5284).