Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
CCK is heading towards enabling application design within Drupal. One feature that would be nice is the (optional) ability to enforce referential integrity for nodereference and userreference.
Has anyone done any thinking/ planning on this? What would this mean for Content Nodes?
If a content node A refers to node B (or user B) then Drupal could guarantee that node A does not get orphaned. This can happen in two ways. 1) Prevention of deletion of node B (user B) while the reference exists or 2) cascading the node deletion.
Love to hear from other developers on this idea.
Comment | File | Size | Author |
---|---|---|---|
#8 | 83929_nodereference_delete.patch | 2.22 KB | hefox |
#3 | referencial_integrity.tar_.gz | 8.8 KB | ycg |
Comments
Comment #1
yched CreditAttribution: yched commentedComment #2
dopry CreditAttribution: dopry commentedi don't see this being implemented any time soon. especially not in CCK.... lets give up this pipe dream until referential integrity lands in core....
Comment #3
ycg CreditAttribution: ycg commentedI have write a module that intends to solve this issue. but it seems the drupal guys does not like it in a separate module so my CVS application was declined.
Currently my modules do tow things
1: Extend the nodereference field to allow cascade delete or delete prevention when a node is referenced by another.
2: Week entity functionality so you can define for any content type a master entity. So i the master entity node form there will be a new task for each week entity that allow administer its childs entities.
here I attach the modules...
Comment #4
markus_petrux CreditAttribution: markus_petrux commentedI'm marking the following issues as dups of this one.
- #204055: Remove node references when the referenced node is deleted
- #346287: Cascade deleting referencing nodes when a parent is deleted
- #391650: Node delete -> nodereference cascade delete
@ycg: I'm not familiar with what happened to your request to a CVS account, but your code has several coding standard issues, also I think a patch would have to be provided here, if it was to be resolved by CCK. So, I marking this issue as "needs work". I'm not sure however it could be approached during the life cycle of CCK for D6 due to lack of time of CCK maintainers.
I would like to mention I'm in need of this feature, and I was about to write a module for that. Maybe yched and/or KarenS can post about if they believe this could be reasolved in CCK2, or otherwise it would be better in contrib, at least for the moment.
Referencial integrity is being introduced in Drupal core for D7, but it seems it will only collect the RI metadata with no real implementation, yet. Reference: #111011: Add foreign keys to core. In any case, RI is not implemented for D6, so something like this would have to be resolved by CCK core, or contrib module.
@yched and/or KarenS: Do you think this can be done for CCK2/3 ?
Comment #5
markus_petrux CreditAttribution: markus_petrux commentedWell, I created a new project that implements basic IR rules (for the moment, only "set null") for user and node reference fields.
http://drupal.org/project/cck_referential_integrity
Cascade and Restrict IR rules are a bit more complex, and I don't need them, so I'll leave it like that for the moment.
So, since I think this won't happen during the life cycle of CCK2 for D6, let's revert the issue status to "won't fix" again.
Comment #6
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedOnce I deleted a node, the nodereference was not deleted. It kept pointing to a node that no longer existed.
I am trying your cck_referential_integrity module and will report back in that queue.
Comment #7
hefox CreditAttribution: hefox commentedSorry for re-opening this, but that node reference doesn't do something for out of the box can leads to errors.
Comment #8
hefox CreditAttribution: hefox commentedHere's a patch for node references; I think it's has issues with what it's doing. I looked at CCK ref integrity and noticed it was doing a lot more complicated processing, but wasn't sure why.
(Figured find out what's wrong with this patch, then do the use reference one).
Comment #9
penyaskitoThe module in #83929-3: referential integrity works for me.
The patches attached only clean the orphan references, but neither of those let's the admin to prevent the deletion.
Comment #10
sergiomazza CreditAttribution: sergiomazza commentedThanks ycg!
Your module is what I was looking
Comment #11
lalit774 CreditAttribution: lalit774 commentedworks for me.