Closed (cannot reproduce)
Project:
Nodereference Count
Version:
6.x-1.1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
18 Aug 2010 at 02:06 UTC
Updated:
28 Jul 2011 at 23:58 UTC
Hi,
When deleting a referenced node, the count inside the original node remains the same even though the referenced content has been deleted. Is there a quick patch that would fix this?
Thanks heaps for the module. It's an awesome addition to the community.
Cheers.
Comments
Comment #1
gilgabar commentedMaybe I'm misunderstanding the problem, but I think this might be a caching issue. Just to make sure we're talking about the same thing let me give a generalized example and you can tell me where I've gone wrong, if I have.
So let's say you have two content types, A and B. A has a nodereference field that references nodes of type B. B has a nodereference count field that is counting those references. Are you saying that you are deleting nodes of type A and the count on the referenced node of type B is not decrementing?
If that is what you are saying, then that should not be happening. It definitely handles the deletion of referencing nodes. The only thing I can think of off the top of my head is that the page is being cached, so the count is not reflecting the actual number at that moment. Try turning off caching to confirm that is not the culprit.
If that is not the problem or if I'm misunderstanding then please follow up and I'll be happy to help troubleshoot further.
Comment #2
webindustries commentedThanks for the reply - much appreciated.
Yes, your detailed description (sorry for missing one out like this) is 100% on the mark. We'll closely monitor our caching and come back to you with what we've found.
Thanks again Gilgabar.
Comment #3
kbm065 commentedThey same thing happens to me. They counter updates when I re-save the referenced node.
Can it be fixed some way?
Comment #4
gilgabar commentedPlease give more details. If you can provide steps to reproduce the issue I would be happy to help troubleshoot and fix the problem.
Comment #5
kbm065 commentedI've tested it on my site, and when just creating two content types and and referencing them, everything works as it should.
But I use the field inside content types which are group content in Organic Groups.
I have two content type which both are normal content in an OG, and when trying to get the counter to work, it will only increase or decrease the counter when I edit the node and save it.
Is it something you could take a look at?
Thanks!
Comment #6
gilgabar commentedCould you clarify your content type and field structure a bit more? Is it something like:
- content type 'group' has a nodereference count field counting references from 'post_a' and 'post_b'
- content type 'post_a' has a nodereference field that references nodes of type 'group'
- content type 'post_b' has a nodereference field that references nodes of type 'group'
As much detail as possible is helpful. Thanks.
Comment #7
kbm065 commentedYes, of course. Sorry for not being more specific.
- content type "group" has no reference field
- content type "post_a" has a nodereference field that references nodes of type "post_b"
- content type "post_b" has a nodereference count field counting references from "post_a".
When creating the nodes I choose the "group" content type they are connected to. Both "post_a" and "post_b" are therefore selected in the settings to be group content nodes, not group nodes.
Was that more helpful? Let me know if you need more information!
Comment #8
gilgabar commentedHmm, I can't replicate the problem. Are there any errors in your log or other info that might give us a clue about what is happening?
Comment #9
twistedindustries commentedI have come across this issue as well and I think I can confirm what is happening, I am just not sure what the fix is yet. I think it has to do with this code:
When I follow that query it is getting the right count. But for example nid 1744 (this node had been deleted) is still referenced in my $table but if you go to the node table it isn't there (as expected).
What I think needs to happen is the query needs to check and make sure that nid in $column exists in the node table. How? I am not sure. I am trying though.
Comment #10
twistedindustries commentedHere is my solution:
In nodereference_count.module on line 117
I changed this:
To this:
It actually seems to give a more accurate count since it doesn't count all the pending revisions as well. Thanks for the great module, now if I would have just found it sooner half my day wouldn't be gone.
Comment #11
momper commentedsubscribe
Comment #12
gilgabar commentedSorry for the delay in responding to this, I've been swamped. I am still unable to replicate this problem.
@twistedindustries could you provide more details about your content type config?
Here is what my test config looks like:
- content type "post_a" has a nodereference field that references nodes of type "post_b"
- content type "post_b" has a nodereference count field counting references from "post_a".
I create a node of type 'post_b', then I create two nodes of type 'post_a', each referencing the same node of type 'post_b'. As expected, the 'post_b' node has a count of two. I look in my database and the '$table' is 'content_type_post_a' which contains two rows, one for each of the nodes referencing the 'post_b' node.
From your description the expected buggy behavior is that I delete one of the nodes of type 'post_a' and it is deleted from the 'node' table, but it leaves the row in the 'content_type_post_a' table. This does not happen. It deletes both the row in the 'node' table as well as in the 'content_type_post_a' table. The count is also decremented on the node of type 'post_b'.
Can you verify that I am understanding your description correctly? Please provide any changes to my testing procedure that would help replicate what you are seeing.
Also regarding the accuracy of the count, 'DISTINCT' makes sure that only unique nids are counted, so revisions are ignored.
Comment #13
fourmi4x commentedHi, I also face a similar issue, but maybe this is a feature request :
When I update a node (of type "post_a") by removing the value of the nodereference field it has, it does not decrease the count.
So I'm not talking about deleting nodes, simply removing a reference.
Is this normal or is it a feature request ?
(I tried the code in #10 without success, tried to clear all caches, tried the "distinct" filter)
Thanks for your help !
Comment #14
gilgabar commentedI was able to reproduce that particular issue and that is a bug. It's not the same as the issue under discussion here though, so I created a separate topic for it #984428: Changing or removing a nodereference does not decrement the count on the formerly referenced node. Thanks.
Comment #15
gilgabar commented