Since the latest version of views was released (yesterday) all of the views where I was utilizing flag have stopped working. (Specifically the queries are just not returning any results when they should be).

I have identified the problem to be in the query itself generated by views, specifically the reference to UID.

For some reason when using the relationship node: (flagged by current user) it thinks the current user is 0 (anon) isntead of the proper UID.

This is the way the query is currently being generated:
FROM node node INNER JOIN flag_content flag_content_node ON node.nid = flag_content_node.content_id AND (flag_content_node.fid = 3 AND flag_content_node.uid = 0)

This is the way the query SHOULD be generated:
FROM node node INNER JOIN flag_content flag_content_node ON node.nid = flag_content_node.content_id AND (flag_content_node.fid = 3 AND flag_content_node.uid = 1)

I will be looking into this further over the next couple of days as this is a high priority issue for my company. If anyone can shed any light or help point me in the right direction my company and I would be very thankful, a previous developer who is no longer with us set up our flagging system and I am unfamiliar with it.

Comments

K.MacKenzie’s picture

Small update:

I have reverted to views 6.x-2.12 (prior to their most recent security update) and the views are working properly again.

The way the query was generated in the older version of views has that portion like this:

INNER JOIN {flag_content} flag_content_node ON node.nid = flag_content_node.content_id AND (flag_content_node.fid = 3 AND flag_content_node.uid = ***CURRENT_USER***)

So I gather the problem is that the newest version of views doesn't like that ***CURRENT_USER*** variable and is replacing it with a 0 by default.

I am afraid that this problem is a bit beyond my understanding of drupal, specifically I dont really even understand how that current user variable works since when I try and run that query through the terminal mysql spits it back at me with a syntax error.

is views supposed to take that current_user variable and convert it before it gets written into the query?

If so, could we possibly help them along somehow by replacing it with the actual UID beforehand.

jacktonkin’s picture

This is a bug in Views. The patch in #1330716: Views substitutions broken after db_safe() update fixes this for me.

quicksketch’s picture

Category: bug » support
Status: Active » Closed (duplicate)
K.MacKenzie’s picture

Category: support » bug
Status: Closed (duplicate) » Fixed

Thank you very much, that was exactly what I was looking for.

http://drupal.org/node/1330716#comment-5200418

K.MacKenzie’s picture

Status: Fixed » Closed (duplicate)

Woops, beat me to it. Thats what I get for not refreshing before I post.