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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Title: Drupal as application builder » referential integrity
Component: General » nodereference.module
dopry’s picture

Status: Active » Closed (won't fix)

i 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....

ycg’s picture

Status: Closed (won't fix) » Needs review
FileSize
8.8 KB

I 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...

markus_petrux’s picture

Version: 4.7.x-1.x-dev » 6.x-2.x-dev
Status: Needs review » Needs work

I'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 ?

markus_petrux’s picture

Status: Needs work » Closed (won't fix)

Well, 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.

SocialNicheGuru’s picture

Once 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.

hefox’s picture

Category: feature » bug
Status: Closed (won't fix) » Active

Sorry for re-opening this, but that node reference doesn't do something for out of the box can leads to errors.

  1. node B is created that references node A
  2. Node A is deleted
  3. A user that does not have permission to edit the node reference field (due to a field access or hook_form_alter) does for node B, and that field is validated and returns that this node cannot be referenced error message, preventing editing of that form which leads to really poor user experience as the user's like "mannnn, what is happening? Why can't I edit this?"
hefox’s picture

Status: Active » Needs work
FileSize
2.22 KB

Here'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).

penyaskito’s picture

The 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.

sergiomazza’s picture

Thanks ycg!
Your module is what I was looking

lalit774’s picture

works for me.