Bug #22535
closedDeleting the parent record leaves orphan child records
0%
Description
I'm using IRRE for 1:n relations and m:n relations with an intermediate table. In both cases deleting the parent record leaves orphan child records. I have tried to fix this by adding foreign keys with ON DELETE CASCADE but after cat I couldn't create new records. An error message 2: SQL error: '' () appears on top of the page in a red box when I try. I guess IRRE tries to save the child record first, before the parent is created.
Having foreign keys would be really nice, but at least IRRE should also delete the child records when their parent is deleted. Until this gets fixed, is there a way I could use some hook to delete the child records manually as a workaround?
(issue imported from #M14233)
Updated by Alexander Stehlik about 12 years ago
- Target version deleted (
0)
I had the same problem that Boros described.
I investigated a bit further and I think I found the problem:
When you look at t3lib_TCEmain::deleteRecord() you can see that when a delete row is configured ($GLOBALS['TCA'][$table]['ctrl']['delete']
) in the TCA the child records will be deleted by:
$this->deleteRecord_procFields($table, $uid, $undeleteRecord);
But when the records are directly deleted without setting a "deleted" flag or the $forceHardDelete
parameter is TRUE
this method (deleteRecord_procFields
) will never be called and the child records stay in the database.
I don't know if this is expected behaviour or if it is a bug. If it is expected, it would be great to get an explanation, why.
Updated by Mathias Schreiber almost 10 years ago
- Target version set to 7.4 (Backend)
- Is Regression set to No
Updated by Susanne Moog over 9 years ago
- Target version changed from 7.4 (Backend) to 7.5
Updated by Markus Klein over 5 years ago
- Is duplicate of Bug #79014: DataHandler not deleting inline and MM references if base table does not have a "delete"-field leads to DatabaseRecordException added