I'm getting duplicate flagged nodes appearing in a view. The view is simple enough: No arguments; no fields (node view); a variety of content types. Nodes flagged by any user (flag is global) are filtered through and should appear.

However if a user flags a node for inclusion in the view, the user sees the node appear twice in the view. Actually any user that has flagged any node sees the duplicates. Users that have not flagged any nodes do not see the duplicates.

Has anyone seen this behavior? Where would I start to find a solution?

Thanks!

Comments

quicksketch’s picture

Category: bug » support

This sounds like a configuration problem with your view. Could you post an export (preferably as an attachment)? I'd suggest removing fields one-by-one until the duplication disappears. You might also try using the "Distinct" option under the view settings.

swortis’s picture

StatusFileSize
new3.23 KB

"Distinct" appears to have worked. Thanks, great tip. I never noticed it before.

(Attaching export of the view as someone may see something strange there.)

quicksketch’s picture

I can't see any problems with the view itself, unless your flag "front_page" was an individual-user flag first, then you changed it to global later (or vice-versa). Another good debugging test is looking at the query that Views generates (it's down at the bottom of the view configuration page), and run it in a normal mySQL terminal or in PHPMyAdmin. If you get duplicate rows in the SQL result, you'll get duplicate rows in Views.

Then again, adding distinct fixes any of these problems, but from the looks of your configuration, it shouldn't really be necessary.

quicksketch’s picture

Status: Active » Fixed

Well regardless distinct has fixed the problem. Please reopen if there are further questions about your duplicate entries.

swortis’s picture

The flag was indeed originally a individual-user flag. I noticed the error, went back and changed it to global, noticed some unexpected behavior and so uninstalled flag and reinstalled it. Perhaps the flags table never was removed?

Anyway, as you say choosing 'distinct' has solved it. Very much appreciate the guidance!

Status: Fixed » Closed (fixed)

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

franz’s picture

Status: Closed (fixed) » Active
StatusFileSize
new6.44 KB

I'm getting that. I'll post the views export here. I've deleted all but the display that matters and the default (there were too many).

After a little debugging, I've found that there are 2 entries at the flag for the node in question, both identical except for the uid (0 and 1). This seems to be generating the duplicated results.

franz’s picture

BTW, this seems to be related with a change of flag settings. The flag was global and the content was flagged. Then the flag changed to user and the content was flagged again. Trying to remove the flag doesn't work, as the flag won't go away. This might be related to another bug.

chrisroditis’s picture

In my case, the DISTINCT only worked when I removed the field "Flags: Flagged time" and the Sort Criteria "Flags: Flagged time". I don't know if that helps in any way.

quicksketch’s picture

Status: Active » Closed (fixed)

Closing after lack of activity.

soulfroys’s picture

Status: Closed (fixed) » Active
StatusFileSize
new12.8 KB

Oh man... I did everything (I gues), if a comment has more than one "abuse flag", it shows duplicate. Any help?

mooffie’s picture

@soulfroys: doesn't 'distinct' solve your problem?

If it doesn't, our short guide to using the Views integration gives a tip: use the counter field and you won't see duplicate records (search that page for "duplicate").

soulfroys’s picture

I tried 'distinct' and the 'counter field', but doesn't work... I simplify my view for best debugging.

I appreciate any help :)

soulfroys’s picture

Modules: flag + flag abuse + flag note. All with the last 6.x-1.x-dev. And the queries:

all_flag_abuse_comment_ORIGINAL:

SELECT comments.cid            AS cid,
       users_flag_content.name AS users_flag_content_name,
       users_flag_content.uid  AS users_flag_content_uid,
       node_comments.title     AS node_comments_title,
       node_comments.nid       AS node_comments_nid,
       node_comments.LANGUAGE  AS node_comments_language,
       comments.name           AS comments_name,
       comments.uid            AS comments_uid,
       comments.homepage       AS comments_homepage,
       comments.COMMENT        AS comments_comment,
       comments.FORMAT         AS comments_format,
       comments.nid            AS comments_nid,
       flag_content.content_id AS flag_content_content_id
FROM   comments comments
       INNER JOIN flag_content flag_content_comments
         ON comments.cid = flag_content_comments.content_id
            AND flag_content_comments.fid = 7
       LEFT JOIN node node_comments
         ON comments.nid = node_comments.nid
       LEFT JOIN users users_flag_content
         ON flag_content_comments.uid = users_flag_content.uid
       LEFT JOIN flag_content flag_content
         ON comments.cid = flag_content.content_id
            AND ( flag_content.fid = 7
                  AND flag_content.uid = *** current_user *** )
WHERE  comments.status = 0 

all_flag_abuse_comment_PLUS_ABUSE_NOTE (I mean, 'flag note relationship'):

SELECT comments.cid            AS cid,
       users_flag_content.name AS users_flag_content_name,
       users_flag_content.uid  AS users_flag_content_uid,
       flag_note_comments.note AS flag_note_comments_note,
       node_comments.title     AS node_comments_title,
       node_comments.nid       AS node_comments_nid,
       node_comments.LANGUAGE  AS node_comments_language,
       comments.name           AS comments_name,
       comments.uid            AS comments_uid,
       comments.homepage       AS comments_homepage,
       comments.COMMENT        AS comments_comment,
       comments.FORMAT         AS comments_format,
       comments.nid            AS comments_nid,
       flag_content.content_id AS flag_content_content_id
FROM   comments comments
       INNER JOIN flag_content flag_content_comments
         ON comments.cid = flag_content_comments.content_id
            AND flag_content_comments.fid = 7
       LEFT JOIN node node_comments
         ON comments.nid = node_comments.nid
       LEFT JOIN users users_flag_content
         ON flag_content_comments.uid = users_flag_content.uid
       INNER JOIN flag_note flag_note_comments
         ON comments.cid = flag_note_comments.content_id
            AND flag_note_comments.fid = 7
       LEFT JOIN flag_content flag_content
         ON comments.cid = flag_content.content_id
            AND ( flag_content.fid = 7
                  AND flag_content.uid = *** current_user *** )
WHERE  comments.status = 0 
mooffie’s picture

all_flag_abuse_comment_PLUS_ABUSE_NOTE.png

But where are the duplicate rows? I don't see them. Can you circle two that are duplicate?

(Thanks for formatting it so nicely!)

mooffie’s picture

I wrote a handbook page explaining this topic:

Getting rid of duplicate rows

mooffie’s picture

Bump.

@soulfroys, can you show me the duplicate rows? If not, I believe the the handbook page (see my previous comment) explains everything there's to know and this issue should be closed.

mooffie’s picture

Status: Active » Closed (works as designed)

I'm getting no response so I'm closing this.

soulfroys’s picture

StatusFileSize
new13.49 KB
new2.27 KB
new111.34 KB
new13.43 KB
new1.28 KB
new137.29 KB

Sorry for the Absence.. :-(

@soulfroys, can you show me the duplicate rows?"
Please, see http://drupal.org/comment/reply/623956#comment-3488522

But.. don't worry, I make another approach (see png).

Tks for all help...