I'm not sure if this is a bug or not but I've noticed when using the relationship API, if either or both related nodes are deleted, the relationship is still left in the relationship table.
I was wondering what is the best way to auto cleanup any orphaned relationships? I was thinking about hooking up to the afterdelete events, but I'm not sure what node types can have relationships defined against them. Anybody got any more info?
Ok, had a crack at the code myself, but really not sure why it's not working. I have a relationship setup between a member and a document, I then have the following setup to detect the deletion of a node and to remove any relationships defined on that node:
Debugging, it hits the event handler, but the call to Relation.GetRelations always returns an empty array. I've also tried it from both ends (ie delete the member first, or delete the document first) but the list always seems to be empty. Anybody got any ideas why this might be?
Ahhhhh. Worked it out. My problem was I didn't have a RelationType defined in the DB. Guess I got a little confused with the documentation I was following as nowhere seems to say you need to setup your relationTypes first. After installing the relation type package and defining the my relations, it all worked fine.
In fact, now that I've defined the relationship type, it does actualy clean up after itself. Maybe there needs to be something to prevent a relationship from being created with an invalid relationship type?
Auto cleanup relationships?
Hi,
I'm not sure if this is a bug or not but I've noticed when using the relationship API, if either or both related nodes are deleted, the relationship is still left in the relationship table.
I was wondering what is the best way to auto cleanup any orphaned relationships? I was thinking about hooking up to the afterdelete events, but I'm not sure what node types can have relationships defined against them. Anybody got any more info?
Many thanks
Matt
Ok, had a crack at the code myself, but really not sure why it's not working. I have a relationship setup between a member and a document, I then have the following setup to detect the deletion of a node and to remove any relationships defined on that node:
Debugging, it hits the event handler, but the call to Relation.GetRelations always returns an empty array. I've also tried it from both ends (ie delete the member first, or delete the document first) but the list always seems to be empty. Anybody got any ideas why this might be?
Many thanks
Matt
Ahhhhh. Worked it out. My problem was I didn't have a RelationType defined in the DB. Guess I got a little confused with the documentation I was following as nowhere seems to say you need to setup your relationTypes first. After installing the relation type package and defining the my relations, it all worked fine.
Matt
In fact, now that I've defined the relationship type, it does actualy clean up after itself. Maybe there needs to be something to prevent a relationship from being created with an invalid relationship type?
Matt
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.