Bug #22535

Deleting the parent record leaves orphan child records

Added by Boros Attila over 9 years ago. Updated 4 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2010-04-28
Due date:
% Done:

0%

TYPO3 Version:
4.3
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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)


Related issues

Duplicates TYPO3 Core - Bug #79014: DataHandler not deleting inline and MM references if base table does not have a "delete"-field leads to DatabaseRecordException⁠⁠⁠⁠ Under Review 2016-12-16

History

#1 Updated by Alexander Stehlik about 7 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.

#2 Updated by Stanislas Rolland over 6 years ago

  • Category set to 978

#3 Updated by Mathias Schreiber almost 5 years ago

  • Target version set to 7.4 (Backend)
  • Is Regression set to No

#4 Updated by Susanne Moog over 4 years ago

  • Target version changed from 7.4 (Backend) to 7.5

#5 Updated by Benni Mack about 4 years ago

  • Target version deleted (7.5)

#6 Updated by Markus Klein 4 months ago

  • Duplicates Bug #79014: DataHandler not deleting inline and MM references if base table does not have a "delete"-field leads to DatabaseRecordException⁠⁠⁠⁠ added

#7 Updated by Markus Klein 4 months ago

  • Status changed from New to Closed

Is handled with #79014

Also available in: Atom PDF