I am having a problem with flags not being recorded when submitted by anonymous users. I am using version 6.x-2.0-beta6, with SessionAPI 6.x-1.4. After reading through documentation pages and the other issues discussing this question, I believe I still need additional help with this process (it is probably something I am missing, rather than a bug, so I have tried to mark this issue as such)
I have created a content type that stores proposals for a local community, and would like community members to vote for those proposals they favor. I wrote a simple view that lists each proposal, along with a "flag this" link and the counter of votes received so far. You can see the list at https://ksacommunity.osu.edu/group/dayton .
When I log in to the site and vote, everything gets recorded successfully. However, when I try to vote anonymously, the flags are not consistently recorded with the counter incrementing. Many of the surrounding behaviors seem correct - the page reloads, the status message reads that the vote has been recorded, and the flag link changes to an unflag link. However, the counter does not increment consistently.
I at first thought that the caching system was the problem - so I added the bit of code from http://drupal.org/node/999102 that reads the page generation time. That timer seems to say that the page is not being served from a cache. Furthermore, when I look at the value for flag_counts.count I see the value not incrementing after I hit the flag link. So that seems to rule out caching.
I have tried using the flag link in the view, and on the node display page. Each seems to work the same way. I built the view using "by any user" in the Flags relationship, as recommended at http://drupal.org/node/999102 (with the exception that I didn't see duplicate results, so didn't seem like I needed the "Distinct" flag recommended - when I enable it, the behavior does not seem to change).
However - and this is where things start to get weird - there are times when the votes -are- recorded. As I am writing this report, I tested anonymous flagging on two computers and three browsers (Chrome, FF, and IE). The first handful of votes (Chrome and FF) did not get recorded although the rest of the behavior seemed correct. When I tested in IE, however, the votes -were- recorded. My next test on the alternate computer in Chrome was also recorded, as was the "remove your vote" link from Firefox on the alternate computer.
I'm hoping that this is enough information to help troubleshoot. I'm a bit mystified at this stage, so I am hoping that someone has seen similar behavior or can point me in a direction of what I've done wrong.
Thanks,
Matt
Comments
Comment #1
morphosis7 commentedAfter further time spent debugging, I believe I can describe the problem more accurately now. I have seen this behavior occur on several computers and several browsers.
1) Visit the page above, that shows a View of nodes with their associated flag links and flag counters. Note the page generation time at the bottom of the page. (12:43:34)
2) Click any given flag link. The page re-loads, a status message is displayed that the vote has been recorded, and the flag link text changes from the "flag this" to the "unflag this" message. The page generation time at the bottom of the page is different from in step 1, so I assume that the content is not being read from a cache. However - the flag counter has not changed.
3) Clicking on the unflag link, the page re-loads again. Again, the appropriate status message is displayed, and the flag link text switches back to the "flag this" message. The page generation time at the bottom of the page is again different. Now, however, the flag counter has been -decreased- by one.
4) Subsequent clicks on the flag link cause all behavior to function as expected.
I have seen the above sequence of steps happen in several contexts, but once you get through the process the link appears to be fixed for the length of that browser session, or perhaps the life of a cookie (haven't tried clearing the cookies yet - but browsers/computer combination I troubleshot with yesterday are still working today).
Comment #2
mattcasey commentedHave you tried constraining the flag Relationship to "current user"? According to the docs, this will disable page caching on that page. I get a similar behavior to yours when I set it to " any user."
Comment #3
morphosis7 commentedI've tried changing that relationship to "current user" - I was hesitant to do this at first because the implication seemed to be that the flag counts would only reflect actions by the current user (i.e. "which nodes have _I_ flagged", rather than "how many flags have these nodes received in total")
On a related question, as I look back over the view definition, there are two relationships - one on "Flags: proposal_votes counter" and another on "Flags: proposal_votes" (by current user). Is there an order in which these two should be listed, or is there a duplication/conflict in having both? I seem to recall needing each, but I may have been wrong at the time.
Matt
Comment #4
radimklaskaI have similar (same?) problem.
My setup:
Sometimes after flagging content, flag count even decreased. => Flag records are deleted.
Try this to reproduce (assuming non-global flag for anonymous users is already set):
SELECT * FROM `flag_content` WHERE `content_id` = '1'(1=node ID of flagged node) Should be empty.SELECT * FROM `flag_counts` WHERE `content_id` = '1'Should be empty too.My opinion is that someone thought this is feature. :-) I think it's not expected behavior and thus it's bug. Any ideas?
Comment #5
radimklaskaI'm pretty sure, this is duplicate of #719616: Keep flag_counts current by manual in/decreasing of count.