Hello everybody!
It's been about two years since i tried to deal with the problem with cascading deletes for DataObjects in SilverStripe with the "janitor" module (
https://github.com/redema/silverstripe-janitor). "janitor" was horrible and slow (it reimplemented referential actions in PHP in order to work with MyISAM) but it got the job done and it supported some nice features in the process.
Much has happened since "janitor" looked like a good idea and when I finally got a chance to start using SilverStripe 3.1 I took a look at "janitor" and got tired by just thinking of how much work it would require to update it to be SilverStripe 3 compatible.
This implementation should probably be viewed as a proof of concept more than anything else, at the moment the code is a bit hacky (to put it mildly) since it must work around a couple of limitations in SilverStripe framework. Only the most basic features are in place:
- support for MySQL databases when the InnoDB-engine is used
- cascading deletes for child table rows when their parent row is deleted
- referential actions for has_one-relations
- support for Versioned DataObjects as long as they only use stages "Stage" and "Live" (note that it is not possible to create referential actions between Versioned and "ordinary" DataObjects - it seems practically impossible to support this in any sane way using only database constraints)
Feedback would be greatly appreciated if anyone finds the problem interesting and has some time to spare.