The Ops field (that is, the "Flag: Flag link") can't be used with the "Flags: User's flagged content" relationship. This patch guards against this (there's an explanation in it).

Here are issues where users report this problem:

#524406: SQL error when using node-based flag Ops in a User view
#888934: problem with Flag link in views

(I invoked the diff command with "-w" because I didn't want the indentation in options_form() to affect the patch.)

CommentFileSizeAuthor
no-ops.diff3.4 KBmooffie

Comments

mooffie’s picture

(BTW, the "peculiarity" of Ops isn't a bug: it's just bad design.)

joachim’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev

Marking #1326410: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users.nid' in 'field list' as a duplicate.

I'm sure the explanation in the patch is good, but it makes my head hurt right now.

Also, if it's bad design, let's redesign it for 7.x-3.x :)

joachim’s picture

Status: Needs review » Needs work

Sooo.... trying to get my head round this :)

What's happening with the "User's flagged content" relationship is that it joins onto the {flag_content} table, BUT via the uid column rather than the content ID column.

And this is why trying to then add the flag op is broken: because to use the flag, you need to have some content to flag!

+++ includes/flag.views.inc
@@ -193,20 +193,21 @@ function flag_views_data_alter(&$data) {
+      'disable flag link' => TRUE,

So I don't think we need this.

+++ includes/flag.views.inc
@@ -193,20 +193,21 @@ function flag_views_data_alter(&$data) {
       'base field' => 'uid',

...because we can simply test this. As in:

- is the base field 'content_id'
--> yes? Flag ops will work!
--> no? It won't!

Furthermore, I think checking this should be done in the handler's validate() method, which means it make the whole view fail validation with an error.

joachim’s picture

Though I've spotted something: once you've made a relationship to flag_content, why can't you then make an onward relationship to a flagged entity? Filed this as #1694956: define a views relationship from {flag_content} towards entities.

ivnish’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

Drupal 7 is EOL. Issue will be closed, but patches are still here