Bug #95541
openStrange behavior of DataHandler regarding hard- and flag-delete with enableCascadingDelete
0%
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