Core bug - Group manager sees their group twice in <site>/og listing

el56 - November 2, 2009 - 18:37
Project:Organic groups
Version:6.x-2.0
Component:Og Views
Category:bug report
Priority:normal
Assigned:Unassigned
Status:postponed
Description

Two different users who are each managers of groups, see their own group twice when viewing page /og as well as "My Groups" (/og/my)

The duplicate entries point to the same (correct) group; they persist for the original owners even if ownership of the group page is changed to someone else.
Non-manager users of the site see the entries properly (once).

#1

kb_0 - November 5, 2009 - 19:26

Can't find my original source on this patch so here is a copy. This is a patch to database.mysql.inc in d6 core that resolved your problem for us. If you use mysqli as a connector instead of mysql, you'll have to patch it instead.

AttachmentSize
d6:database.mysql_.inc_.patch 791 bytes

#2

tchurch - November 5, 2009 - 19:40

Sorry to sound dumb but I have this problem too.

What does one do with the patch?

#3

kb_0 - November 5, 2009 - 19:51

The patch isn't particularly complicated... Instead, just open the file ./includes/database.mysql.inc and change the lines:

    $select = preg_replace(
      '/((?:^|,)\s*)(?<!DISTINCT\()(?:'. $table .'\.)?'. $field .'(\s*(?:,|$))/is',
      '\1'. $field_to_select .'\2', $matches[1], 1
    );

to:

    $select = preg_replace(
      '/((?:^|,|\()\s*)(?<!DISTINCT\()(?:'. $table .'\.)?'. $field .'(\s*(?:,|\sAS|\)|$))/is',
      '\1'. $field_to_select .'\2', $matches[1], 1
    );

This resolved the problem for us.

#4

novacore - November 8, 2009 - 09:33

thanks kb_0, this worked for me too!
i had to change it in /includes/database.mysqli.inc

:-D

#5

bonobo - November 13, 2009 - 00:54

Haven't tested this patch, as I'm not particularly excited about patching core...

We are seeing this as well, and here is some more detail:

For the group creator (ie, the person who created the group node, and is also the manager) the view works as it should.

However, for a user who joins the group and is promoted to group admin, the problem exists (ie, groups are listed twice).

This is not an issue for UID1.

Also, for others reading this thread, hacking core is a VERY bad idea. Kittens die when you do that.

#6

el56 - November 13, 2009 - 15:49

Update:

I've been able to superficially eliminate the display problem within views.

I edited the view "og", subview "page":
.../admin/build/views/edit/og?destination=og#views-tab-page

Under "Basic settings" I changed "Distinct" to "Yes".
So far I haven't seen any unintended consequences, but I suspect that I'm just covering up the problem rather than fixing it.

I, too, maintain a safe fear regarding hacking core.

- Evan

#7

bonobo - November 13, 2009 - 17:23

Forehead <--> Palm!

That's a great workaround --

Like you say, it doesn't actually address the underlying issue, but it does make it go away.

#8

bonobo - November 13, 2009 - 17:50

Actually, setting the view to distinct did not solve this in my case.

The problem still exists.

Still not going to patch core to address this, though.

#9

bonobo - November 14, 2009 - 14:31

This is likely related to #284392: db_rewrite_sql causing issues with DISTINCT.

This is also discussed at http://www.lullabot.com/blog/views-distinct-node-access-problems

We built out a small helper module that works around this. It is working for us in a specific use case, but YMMV. The download is available off the FunnyMonkey site, and is linked from this comment: http://www.lullabot.com/blog/views-distinct-node-access-problems#comment...

#10

marcp - November 14, 2009 - 22:10

Like bonobo said, this is a core issue and it needs more eyes on it. There are steps to reproduce this with minimal fuss here, but I think what would be most helpful would be for people to confirm that this is a problem with PostgreSQL as well as with MySQL.

If you are a pgsql user, please help out with the core issue, which is #284392: db_rewrite_sql causing issues with DISTINCT.

#11

moshe weitzman - November 17, 2009 - 03:30
Title:Group manager sees their group twice in <site>/og listing» Core bug - Group manager sees their group twice in <site>/og listing

retitle. not fixable by OG

#12

bonobo - November 17, 2009 - 13:49
Status:active» postponed

Setting this to postponed (should this be a duplicate?) -- as this should be addressed via #284392: db_rewrite_sql causing issues with DISTINCT.

 
 

Drupal is a registered trademark of Dries Buytaert.