Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6683733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:51:21+00:00 2026-05-26T04:51:21+00:00

I have 2 nodes: Project Bug A project has node references to Bugs When

  • 0

I have 2 nodes:

  • Project
  • Bug

A project has node references to Bugs

When I delete a Bug, those node references remain as orphaned. What is the best way to clean this up?

UPDATE (HERE IS WHAT I DID)

function dc_project_management_node_delete($node)
{
    if ($node->type == 'bug_request')
    {
        $bug_request_nid = $node->nid;
        $milestone_ids = db_query('SELECT entity_id FROM {field_data_field_bugs_requests} WHERE field_bugs_requests_nid = :bug_request_nid', array(':bug_request_nid' => $bug_request_nid))->fetchCol();
        $milestones = entity_load('field_collection_item', $milestone_ids);

        foreach($milestones as $milestone)
        {
            for($k=0;$k<count($milestone->field_bugs_requests['und']);$k++)
            {
                if ($milestone->field_bugs_requests['und'][$k]['nid'] == $bug_request_nid)
                {
                    unset($milestone->field_bugs_requests['und'][$k]);
                }
            }

            entity_save('field_collection_item', $milestone);
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:51:22+00:00Added an answer on May 26, 2026 at 4:51 am

    If you want referential integrity of sorts (i.e. related bugs are deleted when a project is deleted) you could just do this:

    function mymodule_node_delete($node) {
      if ($node->type == 'project') {
        $bug_nids = array();
        foreach ($node->field_bugs[LANGUAGE_NONE] as $bug) {
          $bug_nids[] = $bug['nid'];
        }
    
        node_delete_multiple($bug_nids);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a node Bug/Requests which references one Project. On the project node page,
For a project I'm doing I have a varied number of nodes with node
i already have a project with TreeNode class which creates a hierachy of nodes
I have a project where I have multiple nodes providing services. One ( and
I have some trouble figuring out the best way to store my programming todo
I have a treeview control in a Windows Forms project that has checkboxes turned
I have a standard .NET 3.5 winforms project. On it, it has a treeview.
For a project I need to move Tokens between nodes that have no transitions
I have created a configuration section designer project to represent nodes of a custom
I have several nodes (undirected graph, bidirecional) ... Each two nodes have a distance...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.