The module already supports one IR rule: Set NULL, which is already nice. :)
The next thing would be to implement "Delete cascade" and "Delete restrict".
Implementation of "Delete cascade" would be not so complex as the "Delete restrict" rule. While the former is a minor modification of the current implementation for "Set NULL", the later requires further investigation as it needs to intercept the deletion of users/nodes, during some kind of validation process (that I'm afraid does not exist), and deny the delete operation if references are found, which is something that may involve other contrib modules that may be quite hard to intercept.
Implementation of "Delete cascade" is easy, but it involves deletion of data, and since I don't need this feaure, I'll leave like that for the moment. Patches are welcome.
Comments
Comment #1
markus_petrux commentedhmm... not really a task I would accomplish for the moment, so let's keep it for the record as a "feature request".
Comment #2
markus_petrux commentedBTW, one additional problem with "Delete cascade" is the recursiveness of the operation. "Delete cascade" is not so complex by itself, but it may easily become a tricky problem when mixed with "Delete restrict" rules that could be applied to related nodes.
When "Delete restrict" is implemented, this rule should be enforced first, as it should invalidate Delete operations connected to other IR rules. For example, when node X is deleted, it may affect a nodereference defined with "Delete cascade", but this operation should be denied if recursive delete operations involve a "Delete restrict" rule that finds matches. So before running a Delete cascade operation, we need to scan the whole relations with something like can_delete_cascade(), and this operation should return FALSE whenever a restriction is found.
Eh, it's not as easy as it seems. ;-)
As being said, I don't need this feature, so I'll leave it as it is, with the simple implementation of the "Set NULL" rule. Anyone is welcome to chime in with patches though.
Comment #3
markus_petrux commentedLet me post a few references:
- Designing / Table objects / Constraints (DB2 reference manual).
- CREATE TABLE statement (DB2 reference manual) (scroll down to the FOREIGN KEY section).
References to the MySQL manuals are more obvious, probably, but I'm sure the DB2 manuals are more accurate.
Comment #4
markus_petrux commentedNow that we have a report to monitor orphan records (*), I'm sure I won't work on this feature. Too much work, and too complex.
(*) #511224: Provide a report to list user/node reference fields that point to non-existing users/nodes
Comment #5
fuerst commentedYou may accomplish deletion of orphan nodes referencing the parent node by using Rules actions.
Comment #6
pauldawg commentedAn alternate approach might be in order here. What if the "trash" module were used instead of delete, and then we could just mark content as being in the trash. This would be an easy way of resolving dependencies that one might encounter in situations where referential integrity is critical, but without the overhead of worrying about the database transactional level of referential integrity. Then later one could create jobs to go clean up these objects in the right order by first removing references and then deleting the nodes/users.
Comment #7
cyberwolf commentedI am a little bit disappointed about the way this module is going. Not implementing a "restrict" option for example, will make it possible for content editors to do dangerous things and ending up with data loss ("hey, I have a lot of orphaned nodes here, but to what were they referring again? no idea, the content is gone and the only way to see it again is restoring an old database backup"). Am willing to contribute to this project by checking how complicated it would be to get a "restrict" option in. I am pretty sure there are others who need this feature, if it's not accepted in this project there will probably come up another project implementing it, with duplicate functionality. No need for that I guess.
Comment #8
cyberwolf commentedSeems like Drupal 7 will have the proper hook to implement a "Delete restrict" option, via hook_node_access. Drupal 6 unfortunately does not have this feature. Still searching for another way to accomplish this.
Comment #9
djschoone commentedsubscribing
Comment #10
rp7 commentedDid you find anything to accomplish this?