hello community,

I have been using for more than a year the flag module in combination with rules and session_api without any problems. However a problem has appeared recently.
The usage scenario is the following:
when a user hits a link of a node, he is redirect to a webform, while at the same time rules flag the node on behalf of this anonymous user using the sid.
However redirection is not completed due to a mysql error which is the following

Duplicate entry '2-4858-0-0' for key 2 query: INSERT INTO flag_content (fid, content_type, content_id, uid, sid, timestamp) VALUES (2, 'node', 4858, 0, -1, 1357158786) in /var/www/html/sites/all/modules/flag/flag.inc on line 765.

.

I know that sid should not be -1 instead an id should have been returned. From my little research I found out that session_api is not updated where sid refers to.

Any help/advice is welcomed and appreciated.

PS. In my development I cannot reproduce this, It might be related with the fact I am running the site on localhost.

Comments

joachim’s picture

Status: Active » Postponed (maintainer needs more info)

> when a user hits a link of a node, he is redirect to a webform

Do you mean the flag link on a node? And do you mean the flag confirmation form?
Or something else?

There's an existing issue concerning a sid of -1 -- could you take a look at that please and see if that fixes your problem?

aerodub’s picture

none of them, I mean the link of a node e.g. node/1510. Rules module flag this node (using flag module) when an anonymous user wants to visit a particular node say nid 1510. I should see a corresponding entry in flag_content table for uid=0, however this never happens due to the above error.

I hope I made myself clear.

joachim’s picture

> Rules module flag this node (using flag module) when an anonymous user wants to visit a particular node say nid 1510

Why not use statistics module for this?

aerodub’s picture

Do you mean the built-in module of drupal or another one?
In this case can you post the url?

The problem is that I need to have access to the nodes a anonymous user visits via rules modules. That's why I use flag module due to its integration with rules.

joachim’s picture

Yup, I mean statistics module in Drupal core. IIRC that covers anon users?

In any case, this seems like a really weird use of Flag to me. If you want to track what users are looking at, use a tracking module.

aerodub’s picture

Status: Postponed (maintainer needs more info) » Fixed

joachim,

I solved the problem after looking carefully at the code, it seemed to me very weird but what i did was to change the boolean variable TRUE to true at line 663 of flag.inc file of function flag_get_sid. If it was set to TRUE then $create value was undefined. I do not know if this is related to my php version.

Thanks for your help

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.