Duplicate entries after updating Views, OG.

Justin Hopkins - July 22, 2009 - 15:48
Project:OG Titles
Version:6.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:mradcliffe
Status:fixed
Description

With the most recent stable versions of Views and OG, the dupe problem is back. Where the relationship once helped, it now doesn't. A user with titles in multiple groups will have an entry for each group in every group.

I would consider this a critical problem due to the security issue with the old version of views.

I've tried this with every 6.x version of OG Titles including the CVS fix you supplied earlier in #405272: Titles are not unique 'per group'

Thanks Matthew!

#1

mradcliffe - July 24, 2009 - 20:18

Is this OG 2.x? Or 1.x?

#2

Justin Hopkins - July 26, 2009 - 14:19

Currently using 1.x - I haven't tried updating to OG 2.x, I'll test it with 2.x and report back.

#3

Justin Hopkins - July 26, 2009 - 14:31

So yeah, it happens with OG 1.x and 2.x - it only breaks when I update Views from 6.x-2.3 to 6.x-2.6 -- iirc, the upgrade to 2.4 broke member titles.

#4

elliotttf - July 30, 2009 - 21:21

Subscribing - seeing the same issue here with OG 1.x and Views from Acquia 1.2.13

#5

mradcliffe - August 12, 2009 - 13:28

Sorry for not getting to this. Had a car accident, and am trying to get back on track because of it.

#6

Justin Hopkins - August 17, 2009 - 17:40

No worries. I hope all is well, or on it's way there :)

#7

mradcliffe - August 20, 2009 - 17:33
Assigned to:Anonymous» mradcliffe
Status:active» needs review

Okay, I tested og_titles 1.x with the views 2.6 and og 1.3.

Please confirm that the "Member Title" field does not have the "Group Node" relationship when modifying a field's properties in a view.

See the screenshot below.

AttachmentSize
group-node-relationship.png 86.89 KB

#8

Justin Hopkins - August 24, 2009 - 15:57

Matthew,
I've tried this with every possible combination of modules I can think of, including new and old version of og_titles from CVS. No matter what version of og_titles or OG that I'm using, upgrading from views 2.3 to views 2.6 creates the dupes. The field properties don't look the same for me at all as it does in your screenshot, but I can say this... NOT using the relationship creates only a few duplicates while using it creates a great deal more.

Attached is a screenshot. Currently using the same versions as you did for testing: og_titles 1.0, views 2.6, og 1.3

AttachmentSize
sandbox.png 211.23 KB

#9

Justin Hopkins - August 24, 2009 - 16:22

Following up, I did give the og_titles-6.x-1.x-dev a try and got a view like yours. The problem persists however, with or without the relationship.

#10

mradcliffe - August 26, 2009 - 16:45

What sort of query is views running for this view? If you need to disguise the table name and the database name feel free.

#11

Justin Hopkins - August 30, 2009 - 20:41

Matthew, here is my query. I didn't see any reason to change anything about it.

SELECT users.uid AS uid,
profile_values_profile_firstname.value AS profile_values_profile_firstname_value,
profile_values_profile_lastname.value AS profile_values_profile_lastname_value,
og_uid_titles.title AS og_uid_titles_title,
users.picture AS users_picture,
users.name AS users_name,
profile_values_profile_employedat.value AS profile_values_profile_employedat_value,
profile_values_profile_workphone.value AS profile_values_profile_workphone_value,
users.mail AS users_mail,
og_uid.is_active AS og_uid_is_active,
og_uid.uid AS og_uid_uid,
og_uid.nid AS og_uid_nid,
og_uid.is_admin AS og_uid_is_admin
FROM users users
LEFT JOIN og_uid_titles og_uid_titles ON users.uid = og_uid_titles.uid
LEFT JOIN node node_og_uid_titles ON og_uid_titles.nid = node_og_uid_titles.nid
LEFT JOIN og_uid og_uid_og_uid_titles ON og_uid_titles.uid = og_uid_og_uid_titles.uid AND (og_uid_og_uid_titles.nid = og_uid_titles.nid)
LEFT JOIN og_uid og_uid ON users.uid = og_uid.uid
LEFT JOIN profile_values profile_values_profile_firstname ON users.uid = profile_values_profile_firstname.uid AND profile_values_profile_firstname.fid = '6'
LEFT JOIN profile_values profile_values_profile_lastname ON users.uid = profile_values_profile_lastname.uid AND profile_values_profile_lastname.fid = '7'
LEFT JOIN profile_values profile_values_profile_employedat ON users.uid = profile_values_profile_employedat.uid AND profile_values_profile_employedat.fid = '10'
LEFT JOIN profile_values profile_values_profile_workphone ON users.uid = profile_values_profile_workphone.uid AND profile_values_profile_workphone.fid = '9'
WHERE (users.uid not in ('1')) AND (users.status <> 0) AND (og_uid.is_active <> 0) AND (og_uid.nid = 332)
ORDER BY og_uid_is_admin DESC, og_uid_is_active ASC, users_name ASC, profile_values_profile_lastname_value ASC

*edit:* This is the broken query that produces the duplicates. Here is the query that works properly:
SELECT DISTINCT(users.uid) AS uid,
profile_values_profile_firstname.value AS profile_values_profile_firstname_value,
profile_values_profile_lastname.value AS profile_values_profile_lastname_value,
users.picture AS users_picture,
users.name AS users_name,
og_uid_titles.title AS og_uid_titles_title,
profile_values_profile_employedat.value AS profile_values_profile_employedat_value,
profile_values_profile_workphone.value AS profile_values_profile_workphone_value,
users.mail AS users_mail,
og_uid_og_uid_titles.is_active AS og_uid_og_uid_titles_is_active,
og_uid_og_uid_titles.uid AS og_uid_og_uid_titles_uid,
og_uid_og_uid_titles.nid AS og_uid_og_uid_titles_nid,
og_uid_og_uid_titles.is_admin AS og_uid_og_uid_titles_is_admin
FROM users users
LEFT JOIN og_uid_titles og_uid_titles ON users.uid = og_uid_titles.uid
LEFT JOIN node node_og_uid_titles ON og_uid_titles.nid = node_og_uid_titles.nid
LEFT JOIN og_uid og_uid_og_uid_titles ON og_uid_titles.uid = og_uid_og_uid_titles.uid AND (og_uid_og_uid_titles.nid = og_uid_titles.nid)
LEFT JOIN profile_values profile_values_profile_firstname ON users.uid = profile_values_profile_firstname.uid AND profile_values_profile_firstname.fid = '6'
LEFT JOIN profile_values profile_values_profile_lastname ON users.uid = profile_values_profile_lastname.uid AND profile_values_profile_lastname.fid = '7'
LEFT JOIN profile_values profile_values_profile_employedat ON users.uid = profile_values_profile_employedat.uid AND profile_values_profile_employedat.fid = '10'
LEFT JOIN profile_values profile_values_profile_workphone ON users.uid = profile_values_profile_workphone.uid AND profile_values_profile_workphone.fid = '9'
WHERE (users.uid not in ('1')) AND (users.status <> 0) AND (og_uid_og_uid_titles.is_active <> 0) AND (og_uid_og_uid_titles.nid = 332)
ORDER BY profile_values_profile_lastname_value ASC, og_uid_og_uid_titles_is_admin DESC, og_uid_og_uid_titles_is_active ASC, users_name ASC

#12

mradcliffe - September 3, 2009 - 17:02

Okay, I had some more time to diagnose what's going on.

For every Organic groups user-related field (is_admin, is_active) that you use in sort/filter/field, you will need to have that field use the relationship "Group Member" that og_titles gives you. By default, it will try to create a query that does not connect og_uid_titles and og_uid, which will cause duplicates.

Edit: Remember, the og_uid_titles field, 'member title', should not use a relationship that og_titles provides.

Please have a chance to test this when you can, and sorry for the delays.

AttachmentSize
Picture 2.png 27.79 KB

#13

Justin Hopkins - September 3, 2009 - 18:21

Thanks Matthew. I did what you said and was initially confused when it failed to work - but after adding the 'Group member' relationship to the organic group arguement it *did* solve the problem. It seems a bit odd that this would have fixed it, but hey, whatever works ;) This is a reasonable fix in my mind, but I'll leave it up to you to change the issue status.

Cheers,
Justin

#14

mradcliffe - September 3, 2009 - 18:24
Status:needs review» reviewed & tested by the community

Yes, you'll need to do that for arguments as well. The reason is that by default Og will try to tie its tables with what it uses by default, but if you use the relationship it ties it in with og_titles. When nothing's tied in you get a sql query that usually produces duplicates.

#15

Justin Hopkins - September 6, 2009 - 15:24

For the benefit of others, here is a screenshot of my views config.

AttachmentSize
og_titles_view.png 73.06 KB

#16

ed_conolly - October 7, 2009 - 11:55
Category:bug report» support request
Priority:critical» normal
Status:reviewed & tested by the community» active

Hi,

I'm trying to implement this fix but I can't quite get it to work. I had duplicate groups appearing under the "My Groups" block (view: og_my) and on the main group page (view: og), but only for groups that have been created by authenticated (not admin) users. i.e. is_active and is_admin both are = 1 in og_uid and the uid !=1. This was before using og_titles. Now I've installed og_titles and setup my view to look similar to Justin's screenshot, I now have the view only showing groups for which membership titles have been assigned and the duplicate issue still seems to be occuring in the same way as before .

I've attached the screenshot of my view. I have two questions really, can I set og_titles to give me a default title to all members so that the groups will appear for users who haven't had titles assigned to them? And secondly, how do I get this to work?

Thanks in advance, let me know if anybody needs more detail.

AttachmentSize
og_duplicates_views_scrnshot.png 46.87 KB

#17

ed_conolly - October 7, 2009 - 11:58
AttachmentSize
og_duplicates_views_scrnshot.png 46.87 KB

#18

mradcliffe - October 7, 2009 - 16:39

Interesting. I just tried duplicating what you had there, and I did not get any duplicate entries. I have two entries for two groups for the user in question.

It ran this query

SELECT node.nid AS nid,
   node.title AS node_title
FROM node node
LEFT JOIN og_uid_titles og_uid_titles ON node.nid = og_uid_titles.nid
LEFT JOIN node node_og_uid_titles ON og_uid_titles.nid = node_og_uid_titles.nid
LEFT JOIN og_uid og_uid_og_uid_titles ON og_uid_titles.uid = og_uid_og_uid_titles.uid AND (og_uid_og_uid_titles.nid = og_uid_titles.nid)
WHERE (node.status <> 0) AND (og_uid_og_uid_titles.uid = ***CURRENT_USER***)
   ORDER BY node_title ASC

and I have attached the exported view. Does that look similar to what you're running?

AttachmentSize
og_my_edited.txt 6.58 KB

#19

ed_conolly - October 9, 2009 - 11:50

No problem I managed to fix this, I just used distinct. I had slightly forgotten about it since it's removal from filters...

Thanks all the same.

#20

mradcliffe - October 9, 2009 - 14:57
Status:active» reviewed & tested by the community

#21

drupal92037 - October 26, 2009 - 08:24

I'm sorry but I'm a relative Drupal newbie trying to figure this out. I just set up OG and created one group as a test, and it's showing up twice under "My Groups." What exactly do I have to do to fix it? I understand that I need to modify the View I'm using for the group home page. But what do I change, exactly? The View I'm using looks like this right now (attached). What do I click on?

Thanks.

AttachmentSize
og.png 71.35 KB

#22

mradcliffe - October 30, 2009 - 19:48

Are you talking about the OG module or og_titles? The screenshot looks like a view to display nodes.

I'm not sure if you posted a reply in the correct issue queue...

#23

mompadaddy - November 14, 2009 - 15:36

I think you are in the wrong queue, but you might want to try changing the 'Distinct' option to 'Yes'.

#24

mradcliffe - December 3, 2009 - 20:28
Status:reviewed & tested by the community» fixed
 
 

Drupal is a registered trademark of Dries Buytaert.